mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
38 lines
1.4 KiB
HTML
38 lines
1.4 KiB
HTML
|
<p>给你一个字符串数组 <code>words</code> ,找出并返回数组中的 <strong>第一个回文字符串</strong> 。如果不存在满足要求的字符串,返回一个 <strong>空字符串</strong><em> </em><code>""</code> 。</p>
|
|||
|
|
|||
|
<p><strong>回文字符串</strong> 的定义为:如果一个字符串正着读和反着读一样,那么该字符串就是一个 <strong>回文字符串</strong> 。</p>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>示例 1:</strong></p>
|
|||
|
|
|||
|
<pre><strong>输入:</strong>words = ["abc","car","ada","racecar","cool"]
|
|||
|
<strong>输出:</strong>"ada"
|
|||
|
<strong>解释:</strong>第一个回文字符串是 "ada" 。
|
|||
|
注意,"racecar" 也是回文字符串,但它不是第一个。
|
|||
|
</pre>
|
|||
|
|
|||
|
<p><strong>示例 2:</strong></p>
|
|||
|
|
|||
|
<pre><strong>输入:</strong>words = ["notapalindrome","racecar"]
|
|||
|
<strong>输出:</strong>"racecar"
|
|||
|
<strong>解释:</strong>第一个也是唯一一个回文字符串是 "racecar" 。
|
|||
|
</pre>
|
|||
|
|
|||
|
<p><strong>示例 3:</strong></p>
|
|||
|
|
|||
|
<pre><strong>输入:</strong>words = ["def","ghi"]
|
|||
|
<strong>输出:</strong>""
|
|||
|
<strong>解释:</strong>不存在回文字符串,所以返回一个空字符串。
|
|||
|
</pre>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>提示:</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> 仅由小写英文字母组成</li>
|
|||
|
</ul>
|