Skip to content

Commit b19d5f1

Browse files
authored
Create 1528-shuffle-string.js
1 parent 8f619ee commit b19d5f1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

1528-shuffle-string.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @param {string} s
3+
* @param {number[]} indices
4+
* @return {string}
5+
*/
6+
const restoreString = function(s, indices) {
7+
const n = s.length
8+
const arr = Array(n)
9+
for(let i = 0; i < n; i++) {
10+
arr[indices[i]] = s[i]
11+
}
12+
return arr.join('')
13+
};

0 commit comments

Comments
 (0)