题解 | #替换空格#
替换空格
https://www.nowcoder.com/practice/0e26e5551f2b489b9f58bc83aa4b6c68
class Solution { public: string replaceSpace(string s,string str="",int t=0) { for(int i=0;i<s.size();i++) { if(s[i]==' ') { str=str+s.substr(t,i-t)+"%20"; t=i+1; } } str=str+s.substr(t,s.size()-t); return str; } };