class Solution { public: string replaceSpaces(string &str) { string r; for(auto c:str) { if(c==' ') r+="%20"; else r+=(char)c; } return r; } };