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 f69468c commit f863f03Copy full SHA for f863f03
valid-palindrome/yoonthecoder.js
@@ -0,0 +1,11 @@
1
+var isPalindrome = function (s) {
2
+ // remove any special characters and space from the string
3
+ const formattedString = s.toLowerCase().replace(/[^a-zA-Z0-9]/g, '');
4
+ // use split() method to separate each charaters and put them in an array - reverse it - concatenate
5
+ const reversedString = formattedString.split('').reverse().join('');
6
+
7
+ return reversedString === formattedString;
8
+};
9
10
+// time complexity: O(n)
11
+// space complexity: O(n)
0 commit comments