给你一个字符串 s 和一个 长度相同 的整数数组 indices 。
请你重新排列字符串 s ,其中第 i 个字符需要移动到 indices[i] 指示的位置。返回重新排列后的字符串。
声明:本人,还未学习算法,所以解答中肯定存在非常多的不足,我也会不断修改完善。
def restoreString(s, indices): # 3,1,0,2,4
temp = ''
for i in range(len(indices)): # 0 找到0对应在第几个元素
idx = -1
for j in indices:
idx += 1
if j == i:
temp += s[idx]
break
return temp