File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 79
79
119|[ Pascal's Triangle II] ( ./0119-pascals-triangle-ii.js ) |Easy|
80
80
120|[ Triangle] ( ./0120-triangle.js ) |Medium|
81
81
121|[ Best Time to Buy and Sell Stock] ( ./0121-best-time-to-buy-and-sell-stock.js ) |Easy|
82
+ 125|[ Valid Palindrome] ( ./0125-valid-palindrome.js ) |Easy|
82
83
128|[ Longest Consecutive Sequence] ( ./0128-longest-consecutive-sequence.js ) |Medium|
83
84
133|[ Clone Graph] ( ./0133-clone-graph.js ) |Medium|
84
85
134|[ Gas Station] ( ./0134-gas-station.js ) |Medium|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 125. Valid Palindrome
3
+ * https://leetcode.com/problems/valid-palindrome/
4
+ * Difficulty: Easy
5
+ *
6
+ * A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and
7
+ * removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric
8
+ * characters include letters and numbers.
9
+ *
10
+ * Given a string s, return true if it is a palindrome, or false otherwise.
11
+ */
12
+
13
+ /**
14
+ * @param {string } s
15
+ * @return {boolean }
16
+ */
17
+ var isPalindrome = function ( s ) {
18
+ const string = s . replace ( / [ ^ A - Z \d ] + / ig, '' ) . toLowerCase ( ) ;
19
+ return string . split ( '' ) . reverse ( ) . join ( '' ) === string ;
20
+ } ;
You can’t perform that action at this time.
0 commit comments