MCPcopy Create free account
hub / github.com/Hsinha11/Leetcode-solutions / Solution

Class Solution

valid_palindrome/valid_palindrome.cpp:1–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Solution {
2public:
3 bool isPalindrome(string s) {
4 string filtered;
5 for (char c : s) {
6 if (isalnum(c)) {
7 filtered += tolower(c);
8 }
9 }
10
11 int left = 0;
12 int right = filtered.size() - 1;
13
14 while (left < right) {
15 if (filtered[left] != filtered[right]) {
16 return false;
17 }
18 left++;
19 right--;
20 }
21
22 return true;
23 }
24};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected