Leetcode Problem.125—Valid Palindrome
来源:互联网 发布:java源代码实例 编辑:程序博客网 时间:2024/05/15 04:37
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.
My C++ solution!
string characterOnly(string str){int len=str.length();string r;for(int i=0;i<len;i++){if(('A'<=str[i]&&str[i]<='Z')||('a'<=str[i]&&str[i]<='z')||('0'<=str[i]&&str[i]<='9')) r.append(1,toupper(str[i]));else continue;}return r;}bool isPalindrome(string s){s=characterOnly(s);int len=s.length();for(int i=0;i<(len+1)/2;i++){if(s[i]!=s[len-i-1])return false;}return true;}
0 0
- Leetcode Problem.125—Valid Palindrome
- LeetCode 125: Valid Palindrome
- LeetCode 125 Valid Palindrome
- LeetCode: Valid Palindrome [125]
- leetcode 125-Valid Palindrome
- [leetcode 125] Valid Palindrome
- leetCode #125 Valid Palindrome
- [LeetCode 125] Valid Palindrome
- LeetCode 125 Valid Palindrome
- leetcode-125 Valid Palindrome
- leetcode || 125、Valid Palindrome
- LeetCode---(125) Valid Palindrome
- Leetcode[125]-Valid Palindrome
- leetcode[125]:Valid Palindrome
- Leetcode# 125 Valid Palindrome
- leetcode 125: Valid Palindrome
- leetcode: (125) Valid Palindrome
- [Leetcode]#125 Valid Palindrome
- 黑马程序员——Java基础---单例设计模式
- 在MFC 窗口中运行 cocos2d-x 3.2 (二) 让其在MFC picture控件中运行
- String format 使用
- 八数码问题 poj 1077 康拓展开
- BitMap 学习
- Leetcode Problem.125—Valid Palindrome
- Logging最佳实践
- Swift项目兼容Objective-c问题汇总
- webservice客户端的生成方式
- 黑马程序员-关于IO字符流基础
- 选择 Python3.x or Python2.x
- UIWindow介绍
- 陈怡暖:(午评)欧央行利率决议,希腊欧盟踢皮球
- Leetcode Probem.169—Majority Element