水题
class Solution { public: string addSpaces(string s, vector<int>& spaces) { int len = s.length(); string ret = ""; int i = 0, j = 0; while(i < len) { while(j < spaces.size() && spaces[j] == i) ret += ' ', j++; ret += s[i++]; } return ret; } };
2023-10-03 09:38:40
水题
class Solution { public: string addSpaces(string s, vector<int>& spaces) { int len = s.length(); string ret = ""; int i = 0, j = 0; while(i < len) { while(j < spaces.size() && spaces[j] == i) ret += ' ', j++; ret += s[i++]; } return ret; } };