2025-08-02 18:07:54 +0300 MSK

Decompress Run-Length Encoded List

Code

class Solution:
    def decompressRLElist(self, nums: List[int]) -> List[int]:
        res = []
        i = 0
        length = len(nums)
        while i < length:
            freq, val = nums[i], nums[i + 1]
            i += 2
            res.extend((val, ) * freq)
        return res