125. Valid Palindrome
来源:互联网 发布:查手机mac地址 编辑:程序博客网 时间:2024/06/06 07:25
class Solution {public: bool isPalindrome(string s) { string::iterator low = s.begin(), high = s.end() - 1; while(low < high){ while(!isUpCh(*low) && !isDwnCh(*low) && !isNum(*low)) ++low; while(!isUpCh(*high) && !isDwnCh(*high) && !isNum(*high)) --high; if(low >= high) break; if(*low != *high){ if(isCh(*low) && isCh(*high)){ if(*low - *high == 32 || *high - *low == 32){ ++low; --high; continue; } } return false; } ++low; --high; } return true; } bool isCh(char c){ return (c>=97 && c<=122) || (c>=65 && c<=90); } bool isUpCh(char c){ return c>=97 && c<=122; } bool isDwnCh(char c){ return c>=65 && c<=90; } bool isNum(char c){ return c>=48 && c<=57; }};
阅读全文
0 0
- [LeetCode]125.Valid Palindrome
- LeetCode 125. Valid Palindrome
- [Leetcode] 125. Valid Palindrome
- 【LeetCode】125.Valid Palindrome
- [leetcode] 125.Valid Palindrome
- 125. Valid Palindrome
- [leetcode] 125.Valid Palindrome
- Leetcode 125. Valid Palindrome
- 125. Valid Palindrome
- 125. Valid Palindrome LeetCode
- 125. Valid Palindrome
- 【LeetCode】125. Valid Palindrome
- 125. Valid Palindrome
- 125. Valid Palindrome
- Leetcode 125. Valid Palindrome
- LeetCode 125. Valid Palindrome
- LeetCode 125. Valid Palindrome
- LeetCode *** 125. Valid Palindrome
- hdu1114
- ogg常用函数
- Android如何客制化adb shell进去后显示shell@xxxx的标识
- Android RecyclerView 滚动位置判断
- 【读书笔记】TCP/IP网络编程 第14章 多播、广播
- 125. Valid Palindrome
- Windows 10 安装Spark2.1
- 正则表达式
- 【解决方案】子div用了float浮动之后,如何撑开父元素,让父元素div自动适应高度的问题
- eclipse 查看原始类出现The jar file rt.jar has no source attachment解决方法
- A Research Problem UVA
- 2618: [Cqoi2006]凸多边形
- Selenium element is not attached to the page document
- 正向代理和反向代理