File tree 2 files changed +24
-0
lines changed 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change
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
+ } ;
Original file line number Diff line number Diff line change 243
243
1502|[ Can Make Arithmetic Progression From Sequence] ( ./1502-can-make-arithmetic-progression-from-sequence.js ) |Easy|
244
244
1507|[ Reformat Date] ( ./1507-reformat-date.js ) |Easy|
245
245
1512|[ Number of Good Pairs] ( ./1512-number-of-good-pairs.js ) |Easy|
246
+ 1528|[ Shuffle String] ( ./1528-shuffle-string.js ) |Easy|
246
247
1550|[ Three Consecutive Odds] ( ./1550-three-consecutive-odds.js ) |Easy|
247
248
1551|[ Minimum Operations to Make Array Equal] ( ./1551-minimum-operations-to-make-array-equal.js ) |Medium|
248
249
1566|[ Detect Pattern of Length M Repeated K or More Times] ( ./1566-detect-pattern-of-length-m-repeated-k-or-more-times.js ) |Easy|
You can’t perform that action at this time.
0 commit comments