Skip to content

Commit 588df9a

Browse files
committed
feat: add typescript solution to lc problem: No.1313.Decompress Run-Length Encoded List
1 parent 75c4699 commit 588df9a

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

solution/1300-1399/1313.Decompress Run-Length Encoded List/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@ class Solution {
8282
}
8383
```
8484

85+
### **TypeScript**
86+
87+
```ts
88+
function decompressRLElist(nums: number[]): number[] {
89+
let n = nums.length >> 1;
90+
let ans = [];
91+
for (let i = 0; i < n; i++) {
92+
let freq = nums[2 * i], val = nums[2 * i + 1];
93+
ans.push(...new Array(freq).fill(val));
94+
}
95+
return ans;
96+
};
97+
```
98+
8599
### **C++**
86100

87101
```cpp

solution/1300-1399/1313.Decompress Run-Length Encoded List/README_EN.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,20 @@ class Solution {
7373
}
7474
```
7575

76+
### **TypeScript**
77+
78+
```ts
79+
function decompressRLElist(nums: number[]): number[] {
80+
let n = nums.length >> 1;
81+
let ans = [];
82+
for (let i = 0; i < n; i++) {
83+
let freq = nums[2 * i], val = nums[2 * i + 1];
84+
ans.push(...new Array(freq).fill(val));
85+
}
86+
return ans;
87+
};
88+
```
89+
7690
### **C++**
7791

7892
```cpp
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function decompressRLElist(nums: number[]): number[] {
2+
let n = nums.length >> 1;
3+
let ans = [];
4+
for (let i = 0; i < n; i++) {
5+
let freq = nums[2 * i], val = nums[2 * i + 1];
6+
ans.push(...new Array(freq).fill(val));
7+
}
8+
return ans;
9+
};

0 commit comments

Comments
 (0)