leetcode力扣刷题打卡
题目:1528. 重新排列字符串
描述:给你一个字符串 s 和一个 长度相同 的整数数组 indices 。
请你重新排列字符串 s ,其中第 i 个字符需要移动到 indices[i] 指示的位置。
返回重新排列后的字符串。
解题思路
1、水题,按题目要求写就行了。
原代码##
class Solution {
public:
string restoreString(string s, vector<int>& indices) {
int len = indices.size();
string str = s;
for (int i = 0; i < len; ++i) {
str[indices[i]] = s[i];
}
return str;
}
};