Grokking LinkedIn Coding Interview
Ask Author
Back to course home

0% completed

Vote For New Content
Deepa Subramanian
Regular expression in the solution is wrong.

Deepa Subramanian

Jan 29, 2024

The regular expression given in the solution is wrong. It should be "/^[A-Za-z0-9]/g"

class Solution { // tow pointer solution isPalindrome(s) { let left = 0, right = s.length -1; while(left < right){ while(left < right && !s[left].match(/^[A-Za-z0-9]/g )) { left++ } while(left < right && !s[right].match(/^[A-Za-z0-9]/g )) { right-- } if(s[left].toLowerCase() != s[right].toLowerCase()) return false left++ right-- } // two pointers cross over return true } }

0

0

Comments
Comments

On this page