Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a6b0ee8

Browse files
committed
Add solution #1528
1 parent 985271d commit a6b0ee8

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

1528-shuffle-string.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* 1528. Shuffle String
3+
* https://leetcode.com/problems/shuffle-string/
4+
* Difficulty: Easy
5+
*
6+
* You are given a string s and an integer array indices of the same length.
7+
* The string s will be shuffled such that the character at the ith position
8+
* moves to indices[i] in the shuffled string.
9+
*
10+
* Return the shuffled string.
11+
*/
12+
13+
/**
14+
* @param {string} s
15+
* @param {number[]} indices
16+
* @return {string}
17+
*/
18+
var restoreString = function(s, indices) {
19+
return indices.reduce((result, index, offset) => {
20+
result[index] = s[offset];
21+
return result;
22+
}, new Array(indices.length)).join('');
23+
};

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@
243243
1502|[Can Make Arithmetic Progression From Sequence](./1502-can-make-arithmetic-progression-from-sequence.js)|Easy|
244244
1507|[Reformat Date](./1507-reformat-date.js)|Easy|
245245
1512|[Number of Good Pairs](./1512-number-of-good-pairs.js)|Easy|
246+
1528|[Shuffle String](./1528-shuffle-string.js)|Easy|
246247
1550|[Three Consecutive Odds](./1550-three-consecutive-odds.js)|Easy|
247248
1551|[Minimum Operations to Make Array Equal](./1551-minimum-operations-to-make-array-equal.js)|Medium|
248249
1566|[Detect Pattern of Length M Repeated K or More Times](./1566-detect-pattern-of-length-m-repeated-k-or-more-times.js)|Easy|

0 commit comments

Comments
 (0)