1528. Shuffle String ¶ Time: $O(n)$ Space: $O(n)$ C++ 1 2 3 4 5 6 7 8 9 10 11class Solution { public: string restoreString(string s, vector<int>& indices) { string ans(s.length(), '.'); for (int i = 0; i < indices.size(); ++i) ans[indices[i]] = s[i]; return ans; } };