We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d4ea871 commit 660b8d3Copy full SHA for 660b8d3
101-200/125-valid-palindrome.js
@@ -0,0 +1,30 @@
1
+/*
2
+Author :- Rishabh Jain <contact@rishabh1403.com>
3
+Solution for :- https://leetcode.com/problems/valid-palindrome/
4
+blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-search-insert-position
5
+youtube video :- https://youtu.be/l2XPvyTlC6c
6
+*/
7
+
8
+var isPalindrome = function (s) {
9
+ if (s.length === 0) return true;
10
11
+ s = s.toLowerCase();
12
+ let i = 0, j = s.length - 1;
13
+ while (i < j) {
14
+ if ((s[i] < 'a' || s[i] > 'z') && (s[i] < '0' || s[i] > '9')) {
15
+ i++;
16
+ continue;
17
+ }
18
+ if ((s[j] < 'a' || s[j] > 'z') && (s[j] < '0' || s[j] > '9')) {
19
+ j--;
20
21
22
+ if (s[i] !== s[j]) {
23
+ return false;
24
25
26
27
28
29
+ return true;
30
+};
0 commit comments