package com.fishercoder.solutions;

import java.util.ArrayList;
import java.util.List;

/**
 * 1313. Decompress Run-Length Encoded List
 *
 * We are given a list nums of integers representing a list compressed with run-length encoding.
 * Consider each adjacent pair of elements [a, b] = [nums[2*i], nums[2*i+1]] (with i >= 0).
 * For each such pair, there are a elements with value b in the decompressed list.
 *
 * Return the decompressed list.
 *
 * Example 1:
 * Input: nums = [1,2,3,4]
 * Output: [2,4,4,4]
 * Explanation: The first pair [1,2] means we have freq = 1 and val = 2 so we generate the array [2].
 * The second pair [3,4] means we have freq = 3 and val = 4 so we generate [4,4,4].
 * At the end the concatenation [2] + [4,4,4,4] is [2,4,4,4].
 *
 * Constraints:
 * 2 <= nums.length <= 100
 * nums.length % 2 == 0
 * 1 <= nums[i] <= 100
 * */
public class _1313 {
    public static class Solution1 {
        public int[] decompressRLElist(int[] nums) {
            List<Integer> list = new ArrayList<>();
            for (int i = 0; i < nums.length - 1; i += 2) {
                int count = nums[i];
                int value = nums[i + 1];
                while (count-- > 0) {
                    list.add(value);
                }
            }
            return list.stream().mapToInt(integer -> integer).toArray();
        }
    }
}

@@ -85,779 +85,8 @@
 t;%0A%0A
-/**%0A * 1313. Decompress Run-Length Encoded List%0A *%0A * We are given a list nums of integers representing a list compressed with run-length encoding.%0A * Consider each adjacent pair of elements %5Ba, b%5D = %5Bnums%5B2*i%5D, nums%5B2*i+1%5D%5D (with i %3E= 0).%0A * For each such pair, there are a elements with value b in the decompressed list.%0A *%0A * Return the decompressed list.%0A *%0A * Example 1:%0A * Input: nums = %5B1,2,3,4%5D%0A * Output: %5B2,4,4,4%5D%0A * Explanation: The first pair %5B1,2%5D means we have freq = 1 and val = 2 so we generate the array %5B2%5D.%0A * The second pair %5B3,4%5D means we have freq = 3 and val = 4 so we generate %5B4,4,4%5D.%0A * At the end the concatenation %5B2%5D + %5B4,4,4,4%5D is %5B2,4,4,4%5D.%0A *%0A * Constraints:%0A * 2 %3C= nums.length %3C= 100%0A * nums.length %25 2 == 0%0A * 1 %3C= nums%5Bi%5D %3C= 100%0A * */%0A
 publ

refactor 1313