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 c9407bb commit 11e43f8Copy full SHA for 11e43f8
valid-palindrome/gwbaik9717.js
@@ -0,0 +1,17 @@
1
+// Time complexity: O(n)
2
+// Space complexity: O(n)
3
+
4
+/**
5
+ * @param {string} s
6
+ * @return {boolean}
7
+ */
8
+var isPalindrome = function (s) {
9
+ const normalize = (s) => {
10
+ return s.toLowerCase().replace(/[^a-z0-9]/g, "");
11
+ };
12
13
+ const normalized = normalize(s);
14
+ const reversed = normalized.split("").reverse().join("");
15
16
+ return normalized === reversed;
17
+};
0 commit comments