题解 | #替换空格#

替换空格

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

import java.util.*;


public class Solution {
    public String replaceSpace (String s) {
        String new_str = "";
        int len = s.length();
        for(int i = 0; i < len; i++){
            if(s.charAt(i)==' '){
                new_str = new_str + "%20";
            }
            else{
                new_str = new_str + s.charAt(i);
            }
        }
        return new_str;
    }
}
全部评论

相关推荐

LXXXXd:有点杂,想搞自动化的话没必要把法律的经历写上去
点赞 评论 收藏
分享
10-17 23:18
已编辑
西北农林科技大学 Web前端
独行m:给25可以试试,但他只能给12,那就是纯纯的事精
秋招,不懂就问
点赞 评论 收藏
分享
评论
1
1
分享

创作者周榜

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