125. Valid Palindrome (Array; Two-Pointers)
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
For example,
"A man, a plan, a canal: Panama"
is a palindrome.
"race a car"
is not a palindrome.
Note:
Have you consider that the string might be empty? This is a good question to ask during an interview.
For the purpose of this problem, we define empty string as valid palindrome.
class Solution {
public:
bool isPalindrome(string s) {
if(s.empty()) return true;
int sLength = s.length();
int front = -;
int rear = sLength;
char cFront;
char cRear;
while ()
{
cFront = s[++front];
cRear = s[--rear];
if(front > rear) break;
if(cFront <= 'Z'&& cFront >='A')
{
cFront +=;
}
if(cRear <= 'Z'&& cRear >='A')
{
cRear +=;
}
while( cFront < '' || (cFront < 'a' && cFront > '')|| cFront>'z')
{
cFront = s[++front];
if(front >= rear) break;
if(cFront <= 'Z'&& cFront >='A')
{
cFront +=;
}
}
while( cRear < '' || (cRear < 'a' && cRear > '')|| cRear>'z')
{
cRear = s[--rear];
if(front >= rear) break;
if(cRear <= 'Z'&& cRear >='A')
{
cRear +=;
}
}
if(front >= rear) break;
if(cFront!=cRear)
{
return false;
}
}
return true;
}
};
125. Valid Palindrome (Array; Two-Pointers)的更多相关文章
- 125. Valid Palindrome【easy】
125. Valid Palindrome[easy] Given a string, determine if it is a palindrome, considering only alphan ...
- [LeetCode]题解(python):125 Valid Palindrome
题目来源 https://leetcode.com/problems/valid-palindrome/ Given a string, determine if it is a palindrome ...
- leetcode 125. Valid Palindrome ----- java
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
- LeetCode 125. Valid Palindrome
这个题目只要注意大小写问题即可解决,而且我们只关注的是字母和数值 Given a string, determine if it is a palindrome, considering only a ...
- Java [Leetcode 125]Valid Palindrome
题目描述: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ...
- 【LeetCode】125. Valid Palindrome
题目: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ig ...
- 【一天一道LeetCode】#125. Valid Palindrome
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given a ...
- [leetcode]125. Valid Palindrome判断回文串
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
- LeetCode 125 Valid Palindrome(有效回文)(*)
翻译 给定一个字符串.确定它是否是回文的,仅仅考虑当中的数字和字符并忽略其它. 比如. "A man, a plan, a canal: Panama" 是回文的. "r ...
随机推荐
- ballerina 学习十 streams
ballerina 的streams 使用的是siddhi complex event processing 引擎处理,可以包含的语法有 projection filtering windows jo ...
- Python 函数 -range()
range() pytho range() 函数可创建一个整数列表,一般用在 for 循环中. 语法: range(start, stop[, step]) start: 计数从 start 开始.默 ...
- bzoj 3779 重组病毒——LCT维护子树信息
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3779 调了很久……已经懒得写题解了.https://www.cnblogs.com/Zinn ...
- error: device not found
C:\Users\Administrator>adb shell error: device not found 出现上面情况,首先检查设备管理器中,安卓的驱动是否安装OK? 如果驱动 ...
- 干净的 js测试页面
<!DOCTYPE html><html lang="en" > <head> <meta charset="utf-8&quo ...
- Django在Eclipse下配置启动端口号
首先,在Eclipse左侧树形菜单中找到要更改端口号的项目: 然后,在这里右键选择属性,打开属性界面之后选择Run/Debug Setting,并在其中找到已有的启动项,如果没有可以新建或启动一次. ...
- Solr入门和实践以及我对Solr的8点理解
友情提示Solr的内容还是比较多的,一篇文章只能讲解一部分.全面介绍,没兴趣,没时间,也没能力,回报还不大.本文只写点我认为比较重要的知识点,独特的个人想法.仅供参考哦,更多细节需要自己去琢磨. 概述 ...
- NGUI中LabelA停靠LabelB的方法
详情看 http://note.youdao.com/noteshare?id=ec901d56341207052b2d19233b5ddba3 这里仅仅贴出文字,完整内容请看上面链接. 有这样一个需 ...
- node的socket.io类库概述
socket.io是一个简单的小类库,该类库实现的功能类似于node中的net模块所实现的功能. 这些功能包括websocket通信,xhr轮询,jsonp轮询等. socket类库可以接受所有与服务 ...
- java继承 初始化顺序
java继承 初始化顺序 标签: 初始化顺序 2013-08-01 10:13 879人阅读 评论(0) 收藏 举报 分类: java(8) 版权声明:本文为博主原创文章,未经博主允许不得转载. ...