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

如有错误,多多指教!
边栏推荐
- Selenium:元素等待
- [MySQL] 多表查询
- LeetCode 9. 回文数
- LeetCode 1189. “气球” 的最大数量
- 微信小程序接口调用凭证(获取token)auth.getAccessToken接口开发
- Optional parameters typescript19 - object
- II. Binary tree to Offer 68 - recent common ancestor
- Robot_Framework:常用内置关键字
- Robot_Framework: commonly used built-in keywords
- MySQL-Data Operation-Group Query-Join Query-Subquery-Pagination Query-Joint Query
猜你喜欢

Code Interview Guide for Programmers CD15 Generating an Array of Windowed Maximums

小心你的字典和样板代码

y83. Chapter 4 Prometheus Factory Monitoring System and Actual Combat -- Advanced Prometheus Alarm Mechanism (14)

Dry goods!How to Construct SRv6-TE Performance Test Environment Using Instrumentation

Malicious attacks on mobile applications surge by 500%

剑指 Offer 68 - II. 二叉树的最近公共祖先

Robot_Framework:断言

56:第五章:开发admin管理服务:9:开发【文件上传到,MongoDB的GridFS中,接口】;(把文件上传到GridFS的SOP)

Robot_Framework: commonly used built-in keywords

Power button (LeetCode) 212. The word search II (2022.07.31)
随机推荐
Selenium: Dropdown Box Actions
(2022 Nioke Duo School IV) H-Wall Builder II (Thinking)
2022年湖南工学院ACM集训第六次周测题解
Selenium: element judgment
LeetCode 9. 回文数
JWL-11/2-99.9A电流继电器
小心你的字典和样板代码
Asynchronous reading and writing of files
MySQL-DML language-database operation language-insert-update-delete-truncate
SL-12/2过流继电器
UE4 从鼠标位置射出射线检测
Selenium: Element wait
The difference between scheduleWithFixedDelay and scheduleAtFixedRate
LeetCode 1189. “气球” 的最大数量
Dry goods!How to Construct SRv6-TE Performance Test Environment Using Instrumentation
PaddleX部署推理模型和GUI界面测试结果不一致的解决方法
[MySQL] 多表查询
牛客多校2022第四场A,H,K,N
4D line-by-line analysis and implementation of Transformer, and German translation into English (3)
程序员代码面试指南 CD15 生成窗口最大值数组