Skip to content

Commit 055d30c

Browse files
committed
feat: add typescript solution to lc problem: No.1470.Shuffle the Array
1 parent 7c61caa commit 055d30c

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

solution/1400-1499/1470.Shuffle the Array/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ class Solution {
7979
}
8080
```
8181

82+
### **TypeScript**
83+
84+
```ts
85+
function shuffle(nums: number[], n: number): number[] {
86+
let ans = [];
87+
for (let i = 0; i < n; i++) {
88+
ans.push(nums[i], nums[n + i]);
89+
}
90+
return ans;
91+
};
92+
```
93+
8294
### **C++**
8395

8496
```cpp

solution/1400-1499/1470.Shuffle the Array/README_EN.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,18 @@ class Solution {
101101
}
102102
```
103103

104+
### **TypeScript**
105+
106+
```ts
107+
function shuffle(nums: number[], n: number): number[] {
108+
let ans = [];
109+
for (let i = 0; i < n; i++) {
110+
ans.push(nums[i], nums[n + i]);
111+
}
112+
return ans;
113+
};
114+
```
115+
104116
### **C++**
105117

106118
```cpp
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function shuffle(nums: number[], n: number): number[] {
2+
let ans = [];
3+
for (let i = 0; i < n; i++) {
4+
ans.push(nums[i], nums[n + i]);
5+
}
6+
return ans;
7+
};

0 commit comments

Comments
 (0)