当前位置:网站首页>程序员面试金典面试题 01.03. URL化
程序员面试金典面试题 01.03. URL化
2022-07-22 09:24:00 【yijun009】
class Solution {
public:
string replaceSpaces(string S, int length) {
string res; int i = 0;
for (int i = 0; i < length ; i ++)
if (S[i] == ' '){
res +="%20";
}
else{
res += S[i];
}
return res;
}
};
这个题把res +="%20";
改成res +res +"%20"
;就会超时。最好是在原来的string上移动加修改,字符搬动越少越好,字符复制等比较耗时。
边栏推荐
- Leetcode 2028. find out the missing observation data
- Summary 20220208 (KMP)
- Summary of various technical data -mysql
- PAT乙级1010一元多项式求导(题意理解)
- Unity: 快速定位摄像机Camera
- 微信扫网址的二维码,却只显示链接地址,无法跳转到网页的解决办法
- Log4j log configuration details
- Caching-sha2-password problem occurred when connecting mysql8.0
- 6-2-depth first search underground maze exploration (30 points)
- The database is garbled. Do you want to find a solution?
猜你喜欢
1.常量中有换行符Qt5-》vs的解决方案;2.同一份代码Qt和vs共同编译的问题和解决方案
BigDecimal中除法divide()方法的详细解析,带你走进源码的world
sql 语法中 join 的所有用法总结(简单例子)
leetCode笔记
模块TensorFlow中没有Session
Flink学习笔记(七)处理函数
Caching-sha2-password problem occurred when connecting mysql8.0
LeetCode 105. 从前序与中序遍历序列构造二叉树
mysql主从复制
The detailed analysis of the divide () method in BigDecimal takes you into the world of source code
随机推荐
Leetcode 693. alternating bit binary number
Thymeleaf中一个页面怎么嵌套另一个页面,关于页面嵌套,标签告诉你应该知道的
6-2-深度优先搜索 地下迷宫探索 (30分)
Summary 20220214
Summary 20220208 (KMP)
QT | modal dialog and modeless dialog qdialog
LeetCode 116. 填充每个节点的下一个右侧节点指针
webFlux 中使用 openFeign 实现远程调用遇到的问题
NRF24L01无线模块设置发射接受模式方法
各种资料汇总-网络
Qt | 模态对话框和非模态对话框 QDialog
图像质量评价
PAT乙级1010一元多项式求导(题意理解)
Summary 20220210
模块TensorFlow中没有Session
Summary of various technical data -mysql
numpy.reshape完成图像切割
How to resolve errors in executing the yum makecache command
递归求简单交错幂级数的部分和 (15分)
MySQL的语句执行顺序