LeetCode Valid Palindrome

Description:

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.

Solution:

import java.util.*;

public class Solution {
public boolean isPalindrome(String s) {
int len = s.length();
char ch[] = new char[len];
s = s.toLowerCase();

int tot = 0;
for (int i = 0; i < len; i++) {
char c = s.charAt(i);
if ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9'))
ch[tot++] = c;
}

for (int i = 0; i < tot; i++)
if (ch[i] != ch[tot - 1 - i])
return false;

return true;
}
}

Leetcode算法学习日志-680 valid Palindrome II

2017-09-18 16:16:23

【LeetCode-面试算法经典-Java实现】【125-Valid Palindrome(回文字验证)】

2015-08-14 06:18:42

LeetCode刷题 (Python) | 125. Valid Palindrome

2016-01-30 20:34:28

Leetcode 680 Valid Palindrome II

2017-10-03 11:24:27

【leetcode】680. Valid Palindrome II（Python & C++）

2017-09-19 20:51:14

[C++]Valid Palindrome 有效回文

2015-08-21 11:02:46

Leetcode-680. Valid Palindrome II(判断回文)

2017-10-05 10:37:23

LeetCode125——Valid Palindrome

2015-01-27 18:05:48

Valid Palindrome -- LeetCode

2014-04-02 07:05:57

【LeetCode】- Valid Palindrome（正确的回文）

2014-08-28 08:46:10