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 ith position moves to indices[i] in the shuffled string.
Return the shuffled string.
Create an array to move the characters within the shuffled string into their correct positions. Then, re-concatenate the string from the array.
Move each character in the shuffled string into an array based on the index in the array indices.
temp_array[indices[i]] = shuffled_string.charAt(i)
Re-concatenate the string from the array.
unshuffled_string += temp_array[i]+""
(Add "" to the char to cast to a String type)
For example: shuffled string = rilea and indices = [1, 2, 4, 3, 0]
(At iteration i = 0) temp_array = ['a']
(At iteration i = 1) temp_array = ['a', 'r']
(At iteration i = 2) temp_array = ['a', 'r', 'i']
(At iteration i = 3) temp_array = ['a', 'r', 'i', 'e']
(At iteration i = 4) temp_array = ['a', 'r', 'i', 'e', 'l']
Re-concatenation:
(At iteration i = 0) unshuffled_string = "a"
(At iteration i = 1) unshuffled_string = "ar"
(At iteration i = 2) unshuffled_string = "ari"
(At iteration i = 3) unshuffled_string = "arie"
(At iteration i = 4) unshuffled_string = "ariel"