Skip to content
LC-1313 Easy LeetCode

1313. Decompress Run-Length Encoded List

Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 86% Topics: Array
View full problem on LeetCode

Reading material

Reference solution (spoiler · python)
# Time:  O(n)
# Space: O(1)

class Solution(object):
    def decompressRLElist(self, nums):
        """
        :type nums: List[int]
        :rtype: List[int]
        """
        return [nums[i+1] for i in xrange(0, len(nums), 2) for _ in xrange(nums[i])]

Solution from kamyu104/LeetCode-Solutions · MIT

Similar questions