【Leetcode_easy】917. Reverse Only Letters
problem
solution:
class Solution {
public:
string reverseOnlyLetters(string S) {
for(int i=, j=S.size()-; i<j; )//err...
{
if(!isalpha(S[i])) i++;
else if(!isalpha(S[j])) j--;
else
{
char tmp = S[i];
S[i] = S[j];
S[j] = tmp;
i++;
j--;
}
}
return S;
}
};
参考
1. Leetcode_easy_917. Reverse Only Letters;
完
【Leetcode_easy】917. Reverse Only Letters的更多相关文章
- 【leetcode】917. Reverse Only Letters(双指针)
Given a string s, reverse the string according to the following rules: All the characters that are n ...
- 【LeetCode】917. Reverse Only Letters 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 栈 单指针 双指针 日期 题目地址: https:/ ...
- 【leetcode_easy】557. Reverse Words in a String III
problem 557. Reverse Words in a String III solution1:字符流处理类istringstream. class Solution { public: s ...
- 【leetcode_easy】541. Reverse String II
problem 541. Reverse String II 题意: 给定一个字符串,每隔k个字符翻转这k个字符,剩余的小于k个则全部翻转,否则还是只翻转剩余的前k个字符. solution1: cl ...
- 【leetcode】557. Reverse Words in a String III
Algorithm [leetcode]557. Reverse Words in a String III https://leetcode.com/problems/reverse-words-i ...
- 【LeetCode】#7 Reverse Integer
[Question] Reverse digits of an integer. Example: x = 123, return 321 x = -123, return -321 [My Solu ...
- 【LeetCode】151. Reverse Words in a String
Difficulty: Medium More:[目录]LeetCode Java实现 Description Given an input string, reverse the string w ...
- 【LeetCode】#344 Reverse String
[Question] Write a function that takes a string as input and returns the string reversed. Example: G ...
- [LeetCode] 917. Reverse Only Letters 只翻转字母
Given a string S, return the "reversed" string where all characters that are not a letter ...
随机推荐
- PDB符号文件
一.什么是PDB文件 PDB(Program DataBase),全称为“程序数据库”文件.存储程序的所有调试信息数据.在编译连接时,如果选择了/debug选项或/debug:full选项,则最新的M ...
- 洛谷 P2661 信息传递 题解
P2661 信息传递 题目描述 有 \(n\) 个同学(编号为 \(1\) 到 \(n\) )正在玩一个信息传递的游戏.在游戏里每人都有一个固定的信息传递对象,其中,编号为 \(i\) 的同学的信息传 ...
- 生活中需要一台mac本子
用了好多年的windows系统,各种快捷键玩得飞起.当时对mac笔记本的印象就是. mac本子好高大上,搞设计的人才会去用的.(这个也是我听其他人说的) 在当时公司搞IOS开发的人中,面对这个高大上的 ...
- C++ 如何进阶?
1.C++的用途和意义 总体来说,C++作为一门软件开发语言,它的流行度是在减少的.主要原因在于语言的复杂和灵活导致软件开发成本提高,这体现在开发周期和人力上.它不适用于startup公司的快速开发, ...
- LOJ#565. 「LibreOJ Round #10」mathematican 的二进制 分治,FFT,概率期望
原文链接www.cnblogs.com/zhouzhendong/p/LOJ565.html 前言 标算真是优美可惜这题直接暴力FFT算一算就solved了. 题解 首先,假装没有进位,考虑解决这个问 ...
- Windows下基于IIS服务的SSL服务器的配置
Windows下基于IIS服务的SSL服务器的配置 实验环境 Windows Server 2008 R1(CA) Windows Server 2008 R2(web服务器) Windows 7 x ...
- revenue
美 ['revənju] 英 ['revənjuː] n.收益:营业额:税务署 网络收入:税收:岁入
- spring线程池的应用
加载xml文件 在ApplicationContext.xml文件里面添加 xmlns:task="http://www.springframework.org/schema/task&qu ...
- XAMPP+TestLink
XAMPP(Apache+MySQL+PHP+PERL)是一个功能强大的建站集成软件包.这个软件包原来的名字是 LAMPP,但是为了避免误解,最新的几个版本就改名为 XAMPP 了.它可以在Windo ...
- face-morpher过程函数分析
01 dlib.get_frontal_face_detector #功能:人脸检测画框#参数:无#返回值:默认的人脸检测器 02 points1.astype 转换数组的数据类型 03 np.mea ...