Skip to content

Commit cce794c

Browse files
authored
Create halfofwater.md
1 parent bc71374 commit cce794c

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

2018.11.27-leetcode125/halfofwater.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## leetcode 125
2+
3+
```
4+
class Solution {
5+
public:
6+
bool isPalindrome(string s) {
7+
string::iterator it;
8+
for (it = s.begin(); it != s.end(); it++)
9+
{
10+
//bool b1 = !(65 <= *it && *it <= 90);
11+
//bool b2 = !(97 <= *it && *it <= 122);
12+
//bool b3 = !(48 <= *it && *it <= 57);
13+
14+
if (!(65 <= *it && *it<= 90) && !(97 <= *it && *it <= 122) && !(48 <= *it && *it <= 57))
15+
{
16+
s.erase(it);
17+
it--;
18+
}
19+
if (65 <= *it && *it <= 90)
20+
{
21+
*it += 32;
22+
}
23+
}
24+
int len = s.size();
25+
int i = 0, j = len - 1;
26+
while (i < j)
27+
{
28+
if (s[i] != s[j])
29+
{
30+
return false;
31+
}
32+
i++;
33+
j--;
34+
}
35+
return true;
36+
}
37+
};
38+
```

0 commit comments

Comments
 (0)