刷题-Valid Palindrome 缺python
来源:互联网 发布:软件新城物业公司 编辑:程序博客网 时间:2024/04/27 14:27
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.
java:
public class Solution {
public boolean isPalindrome(String s) {
if (s == null){
return true;
}
else if (s.length()==0){
return true;
}
int i = 0;
int j = s.length()-1;
while (i<=j){
if (!AlNum(s.charAt(i))){
i++;
}
else if (!AlNum(s.charAt(j))){
j--;
}
else if (Character.toLowerCase(s.charAt(i)) == Character.toLowerCase(s.charAt(j))){
i++;
j--;
}
else{
return false;
}
}
return true;
}
public boolean AlNum(char abc){
if (abc >= 'a' && abc <= 'z'){
return true;
}
else if (abc >= 'A' && abc <= 'Z'){
return true;
}
else if (abc >= '0' && abc <= '9'){
return true;
}
else
{
return false;
}
}
}
- 刷题-Valid Palindrome 缺python
- LeetCode刷题 (Python) | 125. Valid Palindrome
- Valid Palindrome Leetcode Python
- [Leetcode][python]Valid Palindrome
- 【LeetCode with Python】 Valid Palindrome
- 125. Valid Palindrome [easy] (Python)
- [leetcode: Python]125. Valid Palindrome
- leetcode Valid Palindrome C++&python 题解
- 【leetcode】125. Valid Palindrome(Python & C++)
- Valid Palindrome
- Valid Palindrome
- Valid Palindrome
- Valid Palindrome
- Valid Palindrome
- Valid Palindrome
- valid palindrome
- Valid Palindrome
- Valid Palindrome
- SQL Server中删除重复数据的几个方法
- apt-get常用命令
- jquery validation 插件使用
- ts_calibrate
- 重新组织函数--Substitute Algorithm(替换算法)
- 刷题-Valid Palindrome 缺python
- 进程和线程的区别
- 时下使用最广泛的几种编程语言的优缺点
- 获取应用的当前版本号&获取当前android系统的版本号
- Fedora 20安装以后的优化
- 刚进公司的菜鸟程序员
- FZU2111
- VS2012 TAB设置为4个空格
- C#代码实现栈