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 ith
position moves to indices[i]
in the shuffled string.
Return the shuffled string.
"""
1528. Shuffle String
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 ith position moves to indices[i] in the shuffled string.
Return the shuffled string.
Input: s = "codeleet", indices = [4,5,6,7,0,2,1,3]
Output: "leetcode"
Explanation: As shown, "codeleet" becomes "leetcode" after shuffling.
"""
s = "aiohn"
indices = [3,1,4,2,0]
word = list(s)
i = 0
while i < len(indices):
word[indices[i]] = s[i]
i += 1
print(''.join(word))