Leetcode 1241 Solution

This article provides solution to leetcode question 1241 (decompress-run-length-encoded-list)

https://leetcode.com/problems/decompress-run-length-encoded-list

Solution

class Solution:
    def decompressRLElist(self, nums: List[int]) -> List[int]:
        ans = []

        i = 0
        while i < len(nums):
            freq = nums[i]
            val = nums[i + 1]
            ans += [val] * freq
            i += 2

        return ans