1313. Decompress Run-Length Encoded List Easy

@problem@discussion
#Array



1/**
2 * [1313] Decompress Run-Length Encoded List
3 *
4 * We are given a list nums of integers representing a list compressed with run-length encoding.
5 * Consider each adjacent pair of elements [freq, val] = [nums[2*i], nums[2*i+1]] (with i >= 0).  For each such pair, there are freq elements with value val concatenated in a sublist. Concatenate all the sublists from left to right to generate the decompressed list.
6 * Return the decompressed list.
7 *  
8 * Example 1:
9 * 
10 * Input: nums = [1,2,3,4]
11 * Output: [2,4,4,4]
12 * Explanation: The first pair [1,2] means we have freq = 1 and val = 2 so we generate the array [2].
13 * The second pair [3,4] means we have freq = 3 and val = 4 so we generate [4,4,4].
14 * At the end the concatenation [2] + [4,4,4] is [2,4,4,4].
15 * 
16 * Example 2:
17 * 
18 * Input: nums = [1,1,2,3]
19 * Output: [1,3,3]
20 * 
21 *  
22 * Constraints:
23 * 
24 * 	2 <= nums.length <= 100
25 * 	nums.length % 2 == 0
26 * 	<font face="monospace">1 <= nums[i] <= 100</font>
27 * 
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/decompress-run-length-encoded-list/
32// discuss: https://leetcode.com/problems/decompress-run-length-encoded-list/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37    pub fn decompress_rl_elist(nums: Vec<i32>) -> Vec<i32> {
38        vec![]
39    }
40}
41
42// submission codes end
43
44#[cfg(test)]
45mod tests {
46    use super::*;
47
48    #[test]
49    fn test_1313() {
50    }
51}
52


Back
© 2025 bowen.ge All Rights Reserved.