problem

917. Reverse Only Letters

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的更多相关文章

  1. 【leetcode】917. Reverse Only Letters(双指针)

    Given a string s, reverse the string according to the following rules: All the characters that are n ...

  2. 【LeetCode】917. Reverse Only Letters 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 栈 单指针 双指针 日期 题目地址: https:/ ...

  3. 【leetcode_easy】557. Reverse Words in a String III

    problem 557. Reverse Words in a String III solution1:字符流处理类istringstream. class Solution { public: s ...

  4. 【leetcode_easy】541. Reverse String II

    problem 541. Reverse String II 题意: 给定一个字符串,每隔k个字符翻转这k个字符,剩余的小于k个则全部翻转,否则还是只翻转剩余的前k个字符. solution1: cl ...

  5. 【leetcode】557. Reverse Words in a String III

    Algorithm [leetcode]557. Reverse Words in a String III https://leetcode.com/problems/reverse-words-i ...

  6. 【LeetCode】#7 Reverse Integer

    [Question] Reverse digits of an integer. Example: x = 123, return 321 x = -123, return -321 [My Solu ...

  7. 【LeetCode】151. Reverse Words in a String

    Difficulty: Medium  More:[目录]LeetCode Java实现 Description Given an input string, reverse the string w ...

  8. 【LeetCode】#344 Reverse String

    [Question] Write a function that takes a string as input and returns the string reversed. Example: G ...

  9. [LeetCode] 917. Reverse Only Letters 只翻转字母

    Given a string S, return the "reversed" string where all characters that are not a letter  ...

随机推荐

  1. 阿里druid数据源配置及数据库密码加密

    注意: 1.阿里默认只对用户密码解密 2.druid 1.0.16版本及以上的解密时需要同时配置publicKey 一.生成密文密码 1 前提:已经配置了jdk环境 1.生成密文密码需要准备druid ...

  2. 谈MongoDB的应用场景

    转载自:http://blog.csdn.net/adparking/article/details/38727911 MongoDB的应用场景在网上搜索了下,很少介绍关于传统的信息化应用中如何使用M ...

  3. c语言冒泡排序算法

    案例一: #include <stdio.h> int main(void){ int a[5]; printf("please input sort number:" ...

  4. 自主设计BootLoader框架笔记一栏

  5. 坑:pytest 运行报错unknown hook 'pytest_namespace' in plugin <module 'allure.pytest_plugin'

    右键运行pytest run时报错,原因是pytest版本过高导致的.有时候会遇到在自己本机没问题,拉取服务器代码下来后就出问题了,所以把pytest版本改低就可以,亲测有效,希望对你有帮助 完整报错 ...

  6. Python字符串转十六进制进制互转

    def str_to_hex(s): return ' '.join([hex(ord(c)).replace('0x', '') for c in s]) def hex_to_str(s): ) ...

  7. Linux 的crond 任务调度

    一.原理示意图 二.概述 任务调度:是指系统在某个时间执行的特定的命令或程序 任务调度分类: 1.系统工作:有些重要的工作周而复始的执行.如病毒扫描等 2.个别用户工作:个别用户可能希望执行程序,比如 ...

  8. mysql数据库出现无法登录(ERROR 1045 ),预防和解决及系列问题解决方法。

      一 .当在windows下使用mysql数据库时,出现无法登录的现象,需要修改mysql数据库的roo密码时,我们可以使用一下两种方法. 1. (1)关闭mysql服务.然后在bin目录下使用cm ...

  9. Oracle的存储的三大物理文件

      分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow 也欢迎大家转载本篇文章.分享知识,造福人民,实现我们中华民族伟大复兴! 一. ...

  10. 实现本地des和aes 解密的工具

    <?php $raw = file_get_contents('php://input'); if(!empty($raw)) { parse_str($raw);//解析到当前作用域 if ( ...