1. 题目描述
请实现一个函数,把字符串 s 中的每个空格替换成"%20"。
0 <= s 的长度 <= 10000
2. 示例
输入:s = “We are happy.”
输出:“We%20are%20happy.”
3. 解法
3.1. 遍历
C++
class Solution {
public:
string replaceSpace(string s) {
string res;
for (char c: s) {
if (' ' != c) {
result.push_back(c);
} else {
res.push_back('%');
res.push_back(