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 41f23d7 commit c6f7608Copy full SHA for c6f7608
valid-palindrome/froggy1014.js
@@ -0,0 +1,22 @@
1
+/**
2
+ * @param {string} s
3
+ * @return {boolean}
4
+ */
5
+
6
+var isPalindrome = function (s) {
7
+ const str = s.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
8
+ let left = 0;
9
+ let right = str.length - 1;
10
11
+ while (left < right) {
12
+ if (str[left] !== str[right]) return false;
13
+ left++;
14
+ right--;
15
+ }
16
17
+ return true;
18
+};
19
20
+console.log(isPalindrome("A man, a plan, a canal: Panama"));
21
+console.log(isPalindrome("race a car"));
22
+console.log(isPalindrome(" "));
0 commit comments