当前位置:网站首页>Leetcode refers to offer jz5 to replace the space string
Leetcode refers to offer jz5 to replace the space string
2022-07-24 06:24:00 【Happy and at ease】

It can be seen from the meaning of the question , Simply traverse the string
#include<iostream>
using namespace std;
class Solution {
public:
/**
* The class name in the code 、 Method name 、 The parameter name has been specified , Do not modify , Return the value specified by the method directly
*
*
* @param s string character string
* @return string character string
*/
string replaceSpace(string s) {
// write code here
for(int i=0;i<s.size();i++){
if(s[i]==' '){
s[i]='%';
s.insert(i+1,"20"); //string Class insert Method insert( Order of strings ,char Type string ) for example s1.insert(6,str2), Is to s1 String number 6 Insert at the end str2 character string
}
}
return s;
}
};
边栏推荐
- Lua Foundation
- ue4换装系统 1.换装系统的基本原理
- [218] what are the advantages and disadvantages of CS architecture and BS architecture and data on the server and client?
- 【217】#!/usr/bin/env 的意义
- Data warehouse and data warehouse modeling
- Map the intranet to the public network [no public IP required]
- Public access intranet IIS website server [no public IP required]
- Force buckle: 1-sum of two numbers
- Dameng database_ User password policy
- IP notes (10)
猜你喜欢

Do not rent servers, build your own personal business website (2)

Heap overflow of kernel PWN basic tutorial

Unity2d game let characters move - next

如何建立一个仪式感点满的网站,并发布到公网 2-2

ue4换装系统 1.换装系统的基本原理

LuckyFrameWeb测试平台(一款支持接口自动化、WEB UI自动化、APP自动化,并且支持分布式测试的全纬度免费开源测试平台)

How does the latest version of text (TMP) UI text of unity display in Chinese
![[no need for public IP] configure a fixed public TCP port address for remote desktop raspberry pie](/img/85/dec6a66dd10c35e2519bd240c05de1.png)
[no need for public IP] configure a fixed public TCP port address for remote desktop raspberry pie

IP课(OSPF)综合实验

Dameng database_ Logical architecture foundation
随机推荐
leetcode剑指offer JZ73 翻转单词序列
Do not rent servers, build your own personal business website (1)
【251】常见的测试工具
Summary of common working methods (7S, SWOT analysis, PDCA cycle, smart principle, 6w2h, time management, WBS, 28 principles)
IA课总结(1)
Dameng database_ Various methods of connecting databases and executing SQL and scripts under disql
Configure a fixed remote desktop address [intranet penetration, no need for public IP]
Jenkins automated unattended operation (up / down)
UE4 reload system 2. Scene capture of reload system
Quickly and simply set up FTP server, and achieve public network access through intranet [no need for public IP]
Unity shader migrated from built-in rendering pipeline to URP
LuckyFrameWeb测试平台(一款支持接口自动化、WEB UI自动化、APP自动化,并且支持分布式测试的全纬度免费开源测试平台)
IP job (2) rip
Use intranet penetration to realize public network access to the Intranet
Openpose2d transform 3D pose recognition
Data warehouse and data warehouse modeling
不租服务器,自建个人商业网站(1)
Unity shader: realize diffuse reflection and specular reflection
Top 10 vulnerability assessment and penetration testing tools
leetcode剑指offer JZ3 数组中重复的数字