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 bac506f commit 9dc2b08Copy full SHA for 9dc2b08
valid-palindrome/JangAyeon.js
@@ -0,0 +1,20 @@
1
+/**
2
+ * @param {string} s
3
+ * @return {boolean}
4
+ */
5
+var isPalindrome = function (s) {
6
+ const sLowered = [...s.toLowerCase().replace(" ", "")];
7
+ const isAlpha = (item) => item.charCodeAt() >= 97 && item.charCodeAt() <= 122;
8
+ const isNumber = (item) => item.charCodeAt() >= 48 && item.charCodeAt() <= 57;
9
+ const str = sLowered.filter((c) => isAlpha(c) || isNumber(c));
10
+ const N = str.length;
11
+ let [start, end] = [0, N - 1];
12
+ while (start <= end) {
13
+ if (str[start] != str[end]) {
14
+ return false;
15
+ }
16
+ start++;
17
+ end--;
18
19
+ return true;
20
+};
0 commit comments