Tap here to switch tabs
Problem
Submissions

Problem: Decompress Run-Length Encoded List

med
30 min
Try to solve the Decompress Run-Length Encoded List problem.

Statement

You are given an integer array nums that represents a list compressed with run length encoding.

Consider each adjacent pair of elements [freq, val] = [nums[2⋅i][2 \cdot i], nums[2⋅i+1][2 \cdot i + 1]] for each i≥0i \geq 0. For every pair, generate freq copies of the value val.

Return the decompressed list formed by concatenating all the generated sublists in order.

Constraints:

  • 2≤2 \leq nums.length ≤100\leq 100

  • nums.length  mod 2=0\bmod 2 = 0

  • 1≤1 \leq nums[i] ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Decompress Run-Length Encoded List

med
30 min
Try to solve the Decompress Run-Length Encoded List problem.

Statement

You are given an integer array nums that represents a list compressed with run length encoding.

Consider each adjacent pair of elements [freq, val] = [nums[2⋅i][2 \cdot i], nums[2⋅i+1][2 \cdot i + 1]] for each i≥0i \geq 0. For every pair, generate freq copies of the value val.

Return the decompressed list formed by concatenating all the generated sublists in order.

Constraints:

  • 2≤2 \leq nums.length ≤100\leq 100

  • nums.length  mod 2=0\bmod 2 = 0

  • 1≤1 \leq nums[i] ≤100\leq 100