题解 | #替换空格#

替换空格

https://www.nowcoder.com/practice/0e26e5551f2b489b9f58bc83aa4b6c68

class Solution {
public:
    string replaceSpace(string s) {
        string new_str = "";
        for (auto& str : s) {
            if (str == ' ') {
                new_str += "%20";
            }
            else new_str += str;
        }
        return new_str;
    }
};

全部评论

相关推荐

不亏是提前批,神仙打架,鼠鼠不配了
站队站对牛:现在92都报工艺岗了
投递韶音科技等公司7个岗位
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-04 14:23
steelhead:你回的有问题,让人感觉你就是来学习的
点赞 评论 收藏
分享
评论
1
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务