当前位置:网站首页>Sword finger offer 05 Replace spaces

Sword finger offer 05 Replace spaces

2022-06-25 15:36:00 anieoo

Original link : The finger of the sword Offer 05. Replace blank space

solution:

        One traversal is enough

class Solution {
public:
    string replaceSpace(string s) {
        string res;
        for(auto &x : s) {
            if(x == ' ') res += "%20";
            else res += x;
        }            
        return res;
    }
};
原网站

版权声明
本文为[anieoo]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206251459277614.html