Skip to content

Commit 9bc5e4e

Browse files
committed
valid palindrome sol
1 parent 1c65b02 commit 9bc5e4e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

valid-palindrome/oyeong011.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
public:
3+
bool isPalindrome(string s) {
4+
string clean = "";
5+
for(char c : s) {
6+
if(isalnum(c)) {
7+
clean += tolower(c);
8+
}
9+
}
10+
11+
string reversed = clean;
12+
reverse(reversed.begin(), reversed.end());
13+
14+
return clean == reversed;
15+
}
16+
};

0 commit comments

Comments
 (0)