Valid Palindrome
来源:互联网 发布:网络词贝塔什么意思 编辑:程序博客网 时间:2024/04/25 19:23
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.
public class Solution { public boolean isPalindrome(String s) { if (s == null || s.trim().length() == 0) {return true;} s = s.toLowerCase(); StringBuilder temp = new StringBuilder(); for (char c : s.toCharArray()) {if ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9')) {temp.append(c);}} return temp.toString().equals(temp.reverse().toString()); }}
0 0
- Valid Palindrome
- Valid Palindrome
- Valid Palindrome
- Valid Palindrome
- Valid Palindrome
- Valid Palindrome
- valid palindrome
- Valid Palindrome
- Valid Palindrome
- Valid Palindrome
- Valid Palindrome
- Valid Palindrome
- Valid Palindrome
- Valid Palindrome
- Valid Palindrome
- Valid Palindrome
- Valid Palindrome
- Valid Palindrome
- android-swipelistview项目打包测试
- Cracking The Coding Interview 3rd -- 1.2
- 大一学生一学期编程量的统计
- 35 Android 在线安装APK
- Word Ladder II
- Valid Palindrome
- 虚拟化,我喜欢
- VC6中怎样引入GDI+?
- 天气又变冷了
- WP Super Cache插件安装
- OER 7451 in Load Indicator : Error Code = OSD-04500 问题处理
- 回家倒计时呀
- 北京设计模式学习组bjdp.org第12次活动(2014.01.10)纪要与下两次活动安排
- 利用register_activation_hook变量初始化失效,解决方法