LeetCode 面试题 01.03. URL化

输入:"Mr John Smith ", 13
输出:“Mr%20John%20Smith”

提示:

字符串长度在 [0, 500000] 范围内。

const replaceSpaces = function(S, length) {
    const _s = S.substr(0, length).split(" ").join("%20")
    return _s
};

replaceSpaces("Mr John Smith    ", 13)

你可能感兴趣的:(LeetCode刷题,javascript,string,leetcode)