mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 03:33:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			39 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<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> </p>
 | 
						|
<p><strong class="example">Example 1:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> words = ["abc","car","ada","racecar","cool"]
 | 
						|
<strong>Output:</strong> "ada"
 | 
						|
<strong>Explanation:</strong> The first string that is palindromic is "ada".
 | 
						|
Note that "racecar" is also palindromic, but it is not the first.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong class="example">Example 2:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> words = ["notapalindrome","racecar"]
 | 
						|
<strong>Output:</strong> "racecar"
 | 
						|
<strong>Explanation:</strong> The first and only string that is palindromic is "racecar".
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong class="example">Example 3:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> words = ["def","ghi"]
 | 
						|
<strong>Output:</strong> ""
 | 
						|
<strong>Explanation:</strong> There are no palindromic strings, so the empty string is returned.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p> </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>
 |