1528. Shuffle String Easy

@problem@discussion
#Array#String



1/**
2 * [1528] Shuffle String
3 *
4 * You are given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the i^th position moves to indices[i] in the shuffled string.
5 * Return the shuffled string.
6 *  
7 * Example 1:
8 * <img alt="" src="https://assets.leetcode.com/uploads/2020/07/09/q1.jpg" style="width: 321px; height: 243px;" />
9 * Input: s = "codeleet", indices = [4,5,6,7,0,2,1,3]
10 * Output: "leetcode"
11 * Explanation: As shown, "codeleet" becomes "leetcode" after shuffling.
12 * 
13 * Example 2:
14 * 
15 * Input: s = "abc", indices = [0,1,2]
16 * Output: "abc"
17 * Explanation: After shuffling, each character remains in its position.
18 * 
19 *  
20 * Constraints:
21 * 
22 * 	s.length == indices.length == n
23 * 	1 <= n <= 100
24 * 	s consists of only lowercase English letters.
25 * 	0 <= indices[i] < n
26 * 	All values of indices are unique.
27 * 
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/shuffle-string/
32// discuss: https://leetcode.com/problems/shuffle-string/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37    pub fn restore_string(s: String, indices: Vec<i32>) -> String {
38        
39    }
40}
41
42// submission codes end
43
44#[cfg(test)]
45mod tests {
46    use super::*;
47
48    #[test]
49    fn test_1528() {
50    }
51}
52


Back
© 2025 bowen.ge All Rights Reserved.