leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
0125.cpp (399B)
0 class Solution {
1 public:
2 bool isPalindrome(string s) {
3 int i = 0, j = s.size() - 1;
4 while (i < j) {
5 if (!isalnum(s[j]))
6 j--;
7 else if (!isalnum(s[i]))
8 i++;
9 else if (tolower(s[i]) != tolower(s[j]))
10 return false;
11 else
12 i++, j--;
13 }
14 return true;
15 }
16 };