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 5d93b0f commit fdeed29Copy full SHA for fdeed29
valid-palindrome/hwanmini.js
@@ -0,0 +1,29 @@
1
+// 시간복잡도: O(n)
2
+// 공간복잡도: O(n)
3
+
4
+/**
5
+ * @param {string} s
6
+ * @return {boolean}
7
+ */
8
+var isPalindrome = function(s) {
9
+ const strs = s.replace(/[^a-z0-9]/gi, '').toLowerCase();
10
11
+ let leftIdx = 0;
12
+ let rightIdx = strs.length - 1
13
14
+ while (leftIdx <= rightIdx) {
15
+ if (strs[leftIdx] !== strs[rightIdx]) return false
16
17
+ leftIdx++
18
+ rightIdx--
19
+ }
20
21
22
+ return true
23
+};
24
25
+const s = "A man, a plan, a canal: Panama"
26
27
28
+console.log(isPalindrome(s))
29
0 commit comments