Description

You are given a string s and an integer array indices of the same length. Shuffle the string such that the character at position i moves to indices[i] in the shuffled string. Return the shuffled string.

Examples

Input:s = "codeleet", indices = [4,5,6,7,0,2,1,3]
Output:"leetcode"
Explanation:

Characters rearranged by indices.

Input:s = "codeleet", indices = [1]
Output:"leetcode"
Explanation:

Rearranging characters according to a single-element index array.

Input:s = "abc", indices = [2,0,1]
Output:"bca"
Explanation:

Character 'a' at position 0 moves to position 2, 'b' at position 1 moves to position 0, and 'c' at position 2 moves to position 1, resulting in "bca".

Constraints

  • s.length == indices.length
  • 1 ≤ s.length ≤ 100

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!