Skip to content

Instantly share code, notes, and snippets.

@koalicioous
Created August 13, 2023 22:54
Show Gist options
  • Save koalicioous/2508f77506996eb996f55c24980df4ca to your computer and use it in GitHub Desktop.
Save koalicioous/2508f77506996eb996f55c24980df4ca to your computer and use it in GitHub Desktop.
125. Valid Palindrome
function isPalindrome(s: string): boolean {
const string = s.replace(/[^A-Za-z0-9]/g, '').toLowerCase()
let left = 0
let right = string.length - 1
while (right > left) {
if (string[left] !== string[right]) return false
right--
left++
}
return true
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment