Skip to content

Commit 23bb2fe

Browse files
Qiu-ITyanglbme
authored andcommitted
feat: add js solution to lc problem: No.1528
1 parent 90f4977 commit 23bb2fe

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

solution/1500-1599/1528.Shuffle String/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,23 @@ func restoreString(s string, indices []int) string {
108108
}
109109
```
110110

111+
### **JavaScript**
112+
113+
```js
114+
/**
115+
* @param {string} s
116+
* @param {number[]} indices
117+
* @return {string}
118+
*/
119+
var restoreString = function (s, indices) {
120+
let rs = [];
121+
for (let i = 0; i < s.length; i++) {
122+
rs[indices[i]] = s[i];
123+
}
124+
return rs.join("");
125+
};
126+
```
127+
111128
### **...**
112129

113130
```

solution/1500-1599/1528.Shuffle String/README_EN.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,23 @@ func restoreString(s string, indices []int) string {
9494
}
9595
```
9696

97+
### **JavaScript**
98+
99+
```js
100+
/**
101+
* @param {string} s
102+
* @param {number[]} indices
103+
* @return {string}
104+
*/
105+
var restoreString = function (s, indices) {
106+
let rs = [];
107+
for (let i = 0; i < s.length; i++) {
108+
rs[indices[i]] = s[i];
109+
}
110+
return rs.join("");
111+
};
112+
```
113+
97114
### **...**
98115

99116
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @param {string} s
3+
* @param {number[]} indices
4+
* @return {string}
5+
*/
6+
var restoreString = function (s, indices) {
7+
let rs = [];
8+
for (let i = 0; i < s.length; i++) {
9+
rs[indices[i]] = s[i];
10+
}
11+
return rs.join("");
12+
};

0 commit comments

Comments
 (0)