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 b4e34de commit 74cea70Copy full SHA for 74cea70
valid-palindrome/reach0908.js
@@ -0,0 +1,27 @@
1
+/**
2
+ * 시간복잡도: O(N)
3
+ * 공간복잡도: O(N)
4
+ * @param {string} s
5
+ * @return {boolean}
6
+ */
7
+const isPalindrome = function (s) {
8
+ const parsedString = s
9
+ .trim()
10
+ .replace(" ", "")
11
+ .replace(/[^a-zA-Z0-9]/g, "")
12
+ .toLowerCase();
13
+
14
+ let left = 0;
15
+ let right = parsedString.length - 1;
16
17
+ while (left < right) {
18
+ if (parsedString[left] !== parsedString[right]) {
19
+ return false;
20
+ }
21
22
+ left += 1;
23
+ right -= 1;
24
25
26
+ return true;
27
+};
0 commit comments