Skip to content

Commit 901a37b

Browse files
authored
Create 1313-decompress-run-length-encoded-list.js
1 parent 1a2411a commit 901a37b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {number[]}
4+
*/
5+
const decompressRLElist = function(nums) {
6+
const res = []
7+
for(let i = 0, n = nums.length; i < n - 1; i += 2) {
8+
const [freq, val] = [nums[i], nums[i + 1]]
9+
for(let j = 0; j < freq; j++) res.push(val)
10+
}
11+
12+
return res
13+
};

0 commit comments

Comments
 (0)