leetcode之Valid Palindrome
来源:互联网 发布:cmd运行java 编辑:程序博客网 时间:2024/04/28 20:06
class Solution {
public:
bool isPalindrome(string s) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if (s.empty()) {
return true;
}
string temp;
for (int i=0; i<s.size(); i++) {
if (isalnum(s[i])) {
temp.push_back(toupper(s[i]));
}
}
if (temp.size()<=1) {
return true;
}
int beg = 0;
int end = temp.size()-1;
while (beg < end) {
if (temp[beg] == temp[end]) {
beg++;
end--;
} else {
return false;
}
}
return true;
}
};
public:
bool isPalindrome(string s) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if (s.empty()) {
return true;
}
string temp;
for (int i=0; i<s.size(); i++) {
if (isalnum(s[i])) {
temp.push_back(toupper(s[i]));
}
}
if (temp.size()<=1) {
return true;
}
int beg = 0;
int end = temp.size()-1;
while (beg < end) {
if (temp[beg] == temp[end]) {
beg++;
end--;
} else {
return false;
}
}
return true;
}
};
- 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之Valid Palindrome 问题
- leetcode:字符串之Valid Palindrome && Palindrome Number
- LeetCode 之 Valid Palindrome — C 实现
- LeetCode 之 Valid Palindrome(字符串)
- [Leetcode] Valid Palindrome
- Leetcode: Valid Palindrome
- leetcode 55: Valid Palindrome
- [LeetCode] Valid Palindrome
- 【leetcode】Valid Palindrome
- LeetCode - Valid Palindrome
- 电脑貌似中毒了 学习YII 困扰两天
- IOS详解TableView —— QQ好友列表的实现
- linux中的 IO端口映射和IO内存映射
- c语言如何操作Oracle之---PRO*C
- POJ3297+map字符串处理
- leetcode之Valid Palindrome
- HDU 1004 Let the Balloon Rise
- Decorator装饰器
- 数组分割
- 一些网络 名词解释
- 润乾——Excel导入
- HDU 4714 Tree2cycle 求树的分叉数 && 2013 ACM/ICPC Asia Regional Online —— Warmup
- stat函数讲解
- 结构体之内存对齐(未完)