java.lang.Object
g1301_1400.s1313_decompress_run_length_encoded_list.Solution

public class Solution extends Object
1313 - Decompress Run-Length Encoded List.<p>Easy</p> <p>We are given a list <code>nums</code> of integers representing a list compressed with run-length encoding.</p> <p>Consider each adjacent pair of elements <code>[freq, val] = [nums[2*i], nums[2*i+1]]</code> (with <code>i >= 0</code>). For each such pair, there are <code>freq</code> elements with value <code>val</code> concatenated in a sublist. Concatenate all the sublists from left to right to generate the decompressed list.</p> <p>Return the decompressed list.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> nums = [1,2,3,4]</p> <p><strong>Output:</strong> [2,4,4,4]</p> <p><strong>Explanation:</strong> The first pair [1,2] means we have freq = 1 and val = 2 so we generate the array [2].</p> <p>The second pair [3,4] means we have freq = 3 and val = 4 so we generate [4,4,4].</p> <p>At the end the concatenation [2] + [4,4,4] is [2,4,4,4].</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> nums = [1,1,2,3]</p> <p><strong>Output:</strong> [1,3,3]</p> <p><strong>Constraints:</strong></p> <ul> <li><code>2 <= nums.length <= 100</code></li> <li><code>nums.length % 2 == 0</code></li> <li><code>1 <= nums[i] <= 100</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • decompressRLElist

      public int[] decompressRLElist(int[] nums)