当前位置:网站首页>使用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;
}
};

如有错误,多多指教!
边栏推荐
- MySQL-DML language-database operation language-insert-update-delete-truncate
- Power button (LeetCode) 212. The word search II (2022.07.31)
- 类神经网络训练不起来怎么办
- (2022牛客多校四)H-Wall Builder II(思维)
- 可视化全链路日志追踪
- Challenge 52 days to memorize Peppa Pig (Day 01)
- Code Interview Guide for Programmers CD15 Generating an Array of Windowed Maximums
- typescript21 - Comparison of Interfaces and Type Aliases
- Optional parameters typescript19 - object
- Swastika line-by-line parsing and realization of the Transformer, and German translation practice (2)
猜你喜欢

小心你的字典和样板代码

(2022 Niu Ke Duo School IV) N-Particle Arts (Thinking)

I met a shell script

Typescript20 - interface

(2022牛客多校四)N-Particle Arts(思维)

typescript28 - value of enumeration type and data enumeration

WPF项目-初步了解数据绑定 binding

Risk strategy important steps of tuning method

SL-12/2过流继电器

(2022 Niu Ke Duo School IV) K-NIO's Sword (Thinking)
随机推荐
【目标检测】YOLOv7理论简介+实践测试
typescript21-接口和类型别名的对比
(2022 Niu Ke Duo School IV) N-Particle Arts (Thinking)
[MySQL] 多表查询
UE4 模型OnClick事件不生效的两种原因
WPF项目-初步了解数据绑定 binding
Selenium:元素判断
Excuse me, only primary key columns can be queried using sql in table storage. Does ots sql not support non-primary keys?
UE4 rays flashed from mouse position detection
2022/07/29 入职健海JustFE团队,我学到了高效开发(年中总结)
56:第五章:开发admin管理服务:9:开发【文件上传到,MongoDB的GridFS中,接口】;(把文件上传到GridFS的SOP)
vim配置+ctag像source insight一样方便阅读代码
万字逐行解析与实现Transformer,并进行德译英实战(三)
NDK does not contain any platforms问题解决
Selenium:操作Cookie
MySQL-DML language-database operation language-insert-update-delete-truncate
WPF项目-按着键盘方向键,移动格子盒子效果
LeetCode 27. 移除元素
typescript26 - literal types
LeetCode 9. 回文数