当前位置:网站首页>使用string 容器翻转 字母
使用string 容器翻转 字母
2022-08-01 05:11:00 【老鱼37】
class Solution {
public:
string reverseOnlyLetters(string s) {
//定位
int begin=0;
int end=s.size()-1;
if(s.empty())
{
return s;
}
while(begin<end)
{
while(begin<end&&!isalpha(s[begin]))//运用判断是否是字母函数isalpha
++begin;
while(begin<end&&!isalpha(s[end]))
--end;
swap(s[begin],s[end]);
++begin;
--end;
}
return s;
}
};
如有错误,多多指教!
边栏推荐
- UE4 从鼠标位置射出射线检测
- PAT乙级 1002 写出这个数
- Optional parameters typescript19 - object
- Selenium:鼠标、键盘事件
- 万字逐行解析与实现Transformer,并进行德译英实战(一)
- 律师解读 | 枪炮还是玫瑰?从大厂之争谈元宇宙互操作性
- Seleniu: Common operations on elements
- Selenium: element positioning
- The solution to the inconsistency between the PaddleX deployment inference model and the GUI interface test results
- Check控件
猜你喜欢
随机推荐
pytroch、tensorflow对比学习—搭建模型范式(低阶、中阶、高阶API示例)
(2022 Niu Ke Duo School IV) K-NIO's Sword (Thinking)
Selenium:上传、下载文件
程序员代码面试指南 CD15 生成窗口最大值数组
Selenium:操作Cookie
Selenium:简介
USB3.0:VL817Q7-C0的LAYOUT指南(二)
ApiFile
The solution to the inconsistency between the PaddleX deployment inference model and the GUI interface test results
PAT serie b write the number 1002
Li Chi's work and life summary in July 2022
MySQL-数据定义语言-DDLdatebase define language
About making a progress bar for software initialization for Qt
Excel record of integer programming optimization model to solve the problem
Seleniu: Common operations on elements
Lawyer Interpretation | Guns or Roses?Talking about Metaverse Interoperability from the Battle of Big Manufacturers
JWL-11/2-99.9A电流继电器
SL-12/2过流继电器
typescript22-接口继承
Swastika line-by-line parsing and realization of the Transformer, and German translation practice (2)