Decompress Run-Length Encoded List Problem

Decompress Run-Length Encoded List Problem — ExecCode Easy DSA Practice

Solve the Decompress Run-Length Encoded List problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given the input needed to solve Decompress Run-Length Encoded List. Your task is to compute the required answer and return the decompressed list. We are given a list nums of integers representing a list compressed with run-length encoding. Consider each adjacent pair of elements [freq, val] = [nums[2 i], nums[2 i+1]] (with i >= 0). For each such pair, there are freq elements with value val concatenated in a sublist. Concatenate all the sublists from left to right to generate the decompressed list.

Examples

Input {"nums": [1, 2, 3, 4]}; Output [2, 4, 4, 4]. Input {"nums": [1, 1, 2, 3]}; Output [1, 3, 3]

Constraints

2 <= nums.length <= 100 nums.length % 2 == 0 1 <= nums[i] <= 100

Practice Decompress Run-Length Encoded List free on ExecCode. Browse DSA problems, topic map, and placement guides.