Practice/Meta/Leetcode 1313. Decompress Run-Length Encoded List
CodingOptional
You are given an array of integers where the elements come in consecutive pairs. Each pair represents compressed data in the format [frequency, value]. Your task is to decompress this data by expanding each pair into a sequence where the value appears exactly frequency times.
The pairs are processed in order from left to right, and all expanded sequences are concatenated together to form the final result.
[freq, val], add val to the output freq times2 <= nums.length <= 100nums.length % 2 == 0 (always even)1 <= nums[i] <= 1001 <= frequency <= 50 for all frequency valuesExample 1:
Input: nums = [1, 2, 3, 4] Output: [2, 4, 4, 4] Explanation: The first pair [1, 2] means "one occurrence of 2", giving us [2]. The second pair [3, 4] means "three occurrences of 4", giving us [4, 4, 4]. Concatenating these gives [2, 4, 4, 4].
Example 2:
Input: nums = [1, 1] Output: [1] Explanation: One occurrence of the value 1.
Example 3:
` Input: nums = [4, 5, 2, 5, 3, 5] Output: [5, 5, 5, 5, 5, 5, 5, 5, 5] Explanation: