class Solution { public: string replaceSpaces(string &str) { size_t t; while((t=str.find(‘ ‘))!=str.npos){//避免find2次 str.replace(t,1,”%20”); } return str; } };