Easy
构造一个长度为字符串的数组,遍历索引,将字符串中对应的字符放到应该在的索引位置上。最后转换成字符串。
以上,AC!
python3
class Solution:
def restoreString(self, s: str, indices: List[int]) -> str:
t = ['' for _ in range(len(s))]
for i,v in enumerate(indices):
t[v] = s[i]
return ''.join(t)