File tree 2 files changed +25
-1
lines changed
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 1
- # 1,751 LeetCode solutions in JavaScript
1
+ # 1,752 LeetCode solutions in JavaScript
2
2
3
3
[ https://leetcodejavascript.com ] ( https://leetcodejavascript.com )
4
4
1614
1614
2104|[ Sum of Subarray Ranges] ( ./solutions/2104-sum-of-subarray-ranges.js ) |Medium|
1615
1615
2105|[ Watering Plants II] ( ./solutions/2105-watering-plants-ii.js ) |Medium|
1616
1616
2106|[ Maximum Fruits Harvested After at Most K Steps] ( ./solutions/2106-maximum-fruits-harvested-after-at-most-k-steps.js ) |Hard|
1617
+ 2108|[ Find First Palindromic String in the Array] ( ./solutions/2108-find-first-palindromic-string-in-the-array.js ) |Easy|
1617
1618
2114|[ Maximum Number of Words Found in Sentences] ( ./solutions/2114-maximum-number-of-words-found-in-sentences.js ) |Easy|
1618
1619
2115|[ Find All Possible Recipes from Given Supplies] ( ./solutions/2115-find-all-possible-recipes-from-given-supplies.js ) |Medium|
1619
1620
2116|[ Check if a Parentheses String Can Be Valid] ( ./solutions/2116-check-if-a-parentheses-string-can-be-valid.js ) |Medium|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 2108. Find First Palindromic String in the Array
3
+ * https://leetcode.com/problems/find-first-palindromic-string-in-the-array/
4
+ * Difficulty: Easy
5
+ *
6
+ * Given an array of strings words, return the first palindromic string in the array. If there is
7
+ * no such string, return an empty string "".
8
+ *
9
+ * A string is palindromic if it reads the same forward and backward.
10
+ */
11
+
12
+ /**
13
+ * @param {string[] } words
14
+ * @return {string }
15
+ */
16
+ var firstPalindrome = function ( words ) {
17
+ for ( const word of words ) {
18
+ if ( word === word . split ( '' ) . reverse ( ) . join ( '' ) ) {
19
+ return word ;
20
+ }
21
+ }
22
+ return '' ;
23
+ } ;
You can’t perform that action at this time.
0 commit comments