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 04e072c commit db404baCopy full SHA for db404ba
valid-palindrome/choidabom.js
@@ -0,0 +1,28 @@
1
+/**
2
+ * Runtime: 7ms, Memory: 55.02MB
3
+ *
4
+ * Time Complexity: O(n)
5
+ * Space Complexity: O(n)
6
+*/
7
+
8
9
+ * @param {string} s
10
+ * @return {boolean}
11
+ */
12
+function isPalindrome(s) {
13
+ const alphanumeric = getAlphanumeric(s)
14
+ return alphanumeric === alphanumeric.split("").reverse().join("")
15
+}
16
17
+function getAlphanumeric(string) {
18
+ const number = /[0-9]/
19
+ const alphabet = /[a-zA-Z]/
20
+ let alphanumeric = []
21
22
+ for (const str of string) {
23
+ if (number.test(str) || alphabet.test(str)) {
24
+ alphanumeric.push(str)
25
+ }
26
27
+ return alphanumeric.join("").toLowerCase()
28
0 commit comments