leetcode4 Valid Palindrome回文数

  Valid Palindrome回文数

  whowhoha@outlook.com

Question:

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.

解决方法:使用两个指针,分别指向头尾,然后向中间移动依次判断

int isPalindrome(string s)

{

int i=0,j=s.size()-1;

if (j==0)

{

return 0;

}

while(i<j)

{

if (s[i++] != s[j--])

{

return 0;

}

}

return 1;

}

上一篇:Android驱动之 Linux Input子系统之TP——A/B(Slot)协议


下一篇:HTML5 移动应用开发环境搭建及原理分析