Valid Palindrome 原

zhuguorong

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.

``````import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;

/*
* 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.
* */
public class Solution {

public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(Solution.isPalindrome("race a car"));
}
public static boolean isPalindrome(String s) {
if(s == null&&s.length() == 0)
return true;
String slow = s.toLowerCase();
char[] cc = slow.toCharArray();
Stack<Character> stack = new Stack<>();
for(int i = 0 ; i < cc.length;i++)
{
if((cc[i]>='0'&&cc[i]<='9')||(cc[i]>='a'&&cc[i]<='z'))
{
stack.push(cc[i]);
}

}
boolean flag = true;
while(!stack.isEmpty())
{
if(stack.pop()!=queue.remove())
{
flag = false;
break;
}
}
return flag;
}
}
``````

zhuguorong

leetCode 125. Valid Palindrome 字符串

125. Valid Palindrome Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, is a palindrome. is not a palind......

wbf961127
2017/11/13
0
0

2016/12/22
1
0
[LeetCode] Valid Palindrome II 验证回文字符串之二

Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. Example 1: Input: "aba"Output: True Example 2: Input: "abca"Output:......

2017/12/06
0
0
LeetCode：Valid Palindrome - 回文字符串

1、题目名称 Valid Palindrome（回文字符串） 2、题目地址 https://leetcode.com/problems/valid-palindrome/ 3、题目内容 英文：Given a string, determine if it is a palindrome, consid......

2015/08/05
0
0

LeetCode 125：Valid Palindrome（有效回文） Q:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the purpose ......

2018/08/18
0
0

table边框样式

table{ border:0.5px solid #000; border-collapse:collapse; //去除边框间空隙}th,td{ border:0.5px solid #000;}...

21分钟前
1
0

26分钟前
1
0
Vue Element表单绑定（四）常用操作整理

tianma3798
31分钟前
1
0
《大话数据结构》读后总结（七）

32分钟前
0
0
three.js 事件交互

tianyawhl
33分钟前
1
0