Class Solution
java.lang.Object
g2101_2200.s2108_find_first_palindromic_string_in_the_array.Solution
2108 - Find First Palindromic String in the Array.<p>Easy</p>
<p>Given an array of strings <code>words</code>, return <em>the first <strong>palindromic</strong> string in the array</em>. If there is no such string, return <em>an <strong>empty string</strong></em> <code>""</code>.</p>
<p>A string is <strong>palindromic</strong> if it reads the same forward and backward.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> words = [“abc”,“car”,“ada”,“racecar”,“cool”]</p>
<p><strong>Output:</strong> “ada”</p>
<p><strong>Explanation:</strong> The first string that is palindromic is “ada”. Note that “racecar” is also palindromic, but it is not the first.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> words = [“notapalindrome”,“racecar”]</p>
<p><strong>Output:</strong> “racecar”</p>
<p><strong>Explanation:</strong> The first and only string that is palindromic is “racecar”.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> words = [“def”,“ghi”]</p>
<p><strong>Output:</strong> ""</p>
<p><strong>Explanation:</strong> There are no palindromic strings, so the empty string is returned.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= words.length <= 100</code></li>
<li><code>1 <= words[i].length <= 100</code></li>
<li><code>words[i]</code> consists only of lowercase English letters.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
isPalindrome
-
firstPalindrome
-