leetcode:Valid Palindrome
来源:互联网 发布:区域网络管理 编辑:程序博客网 时间:2024/06/14 14:02
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) return true; s = s.toLowerCase(); char[] ch = new char[s.length()]; int m = 0; for(int i = 0;i< s.length();i++){ if((s.charAt(i) >= '0' && s.charAt(i) <= '9') || (s.charAt(i) >= 'a' && s.charAt(i) <= 'z')){ ch[m] = s.charAt(i); m++; } } int j = 0; for(int i = ch.length-1;i >=0;i--){ if(!((ch[i] >= '0' && ch[i] <= '9')||(ch[i] >= 'a' && ch[i] <= 'z'))) continue; else{ if(ch[i] != ch[j]) return false; j++; } } return true; }}
0 0
- [Leetcode] Valid Palindrome
- Leetcode: Valid Palindrome
- leetcode 55: Valid Palindrome
- [LeetCode] Valid Palindrome
- 【leetcode】Valid Palindrome
- LeetCode - Valid Palindrome
- [leetcode]Valid Palindrome
- [LeetCode]Valid Palindrome
- [Leetcode]Valid Palindrome
- LeetCode-Valid Palindrome
- [leetcode] Valid Palindrome
- LeetCode 125: Valid Palindrome
- LeetCode - Valid Palindrome
- leetcode之Valid Palindrome
- LeetCode | Valid Palindrome
- [leetcode]Valid Palindrome
- 【leetcode】Valid Palindrome
- LeetCode题解:Valid Palindrome
- Log4net使用
- Android 各大网络请求库的比较及实战
- 如何在shell中判断一个文件是否为空
- MYSQL查询优化:profile功能
- Hough Transform 与矩形检测。
- leetcode:Valid Palindrome
- ApiController的过滤器使用
- 正则表达式学习总结(python版)
- Android-网络框架
- android开关屏幕
- Quartz Core 图层编程
- android framework 重启LOG分析方法
- Django 静态文件配置
- linux中某个端口拒绝远程主机连接原因及解决方法