Skip to content

Commit 3b86fe8

Browse files
committed
add : solution of the is_palindrome
1 parent df0d71c commit 3b86fe8

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

valid-palindrome/aa601.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
bool isPalindrome(char* s) {
2+
int i;
3+
int j;
4+
int size;
5+
char tmp;
6+
int flag;
7+
8+
i = 0;
9+
size = strlen(s);
10+
j = size - 1;
11+
flag = 1;
12+
while (i < j) {
13+
if (!isalnum(s[i])) {
14+
++i;
15+
continue ;
16+
}
17+
else if (!isalnum(s[j])) {
18+
--j;
19+
continue ;
20+
}
21+
if (tolower(s[i++]) != tolower(s[j--])) {
22+
flag = 0;
23+
break ;
24+
}
25+
}
26+
return (flag);
27+
}

0 commit comments

Comments
 (0)