class Solution { public: void replaceSpace(char *str,int length) { string s(str); string res; for(auto &x:s){ if(x==' ') res+="%20"; else res+=x; } auto ret=res.c_str(); strcpy(str,ret); } };
class Solution { public: void replaceSpace(char *str,int length) { string s(str); string res; for(auto &x:s){ if(x==' ') res+="%20"; else res+=x; } auto ret=res.c_str(); strcpy(str,ret); } };