2109. 向字符串添加空格
作者:互联网
水题
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; } };
标签:string,int,while,ret,空格,2109,spaces,len,字符串 来源: https://www.cnblogs.com/WTSRUVF/p/15848847.html