当前位置:网站首页>使用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;
}
};
如有错误,多多指教!
边栏推荐
猜你喜欢
typescript23-tuple
pytroch、tensorflow对比学习—专栏介绍
(2022牛客多校四)H-Wall Builder II(思维)
(2022 Niu Ke Duo School IV) N-Particle Arts (Thinking)
The method of solving stored procedure table name passing through variable in mysql
MySQL-DML语言-数据库操作语言-insert-update-delete-truncate
(2022 Niu Ke Duo School IV) K-NIO's Sword (Thinking)
[target detection] YOLOv7 theoretical introduction + practical test
typescript22-接口继承
(Codeforce 757)E. Bash Plays with Functions(积性函数)
随机推荐
PAT乙级 1002 写出这个数
图片更新之后Glide加载依旧是原来的图片问题
MySQL-DML language-database operation language-insert-update-delete-truncate
Selenium:表单切换
MySQL-数据定义语言-DDLdatebase define language
Robot_Framework:关键字
typescript28 - value of enumeration type and data enumeration
万字逐行解析与实现Transformer,并进行德译英实战(三)
【MySQL必知必会】 表的优化 | 充分利用系统资源
Power button (LeetCode) 212. The word search II (2022.07.31)
Robot_Framework: Assertion
25. 这三道常见的面试题,你有被问过吗?
对话MySQL之父:一个优秀程序员可抵5个普通程序员
y83.第四章 Prometheus大厂监控体系及实战 -- prometheus告警机制进阶(十四)
李迟2022年7月工作生活总结
In the shake database, I want to synchronize the data of the source db0 to the destination db5, how to set the parameters?
Dry goods!How to Construct SRv6-TE Performance Test Environment Using Instrumentation
pytroch、tensorflow对比学习—专栏介绍
MySQL-Data Definition Language-DDLdatebase define language
typescript27 - what about enumeration types