1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/找出数组中的第一个回文字符串 [find-first-palindromic-string-in-the-array].html
2022-03-29 12:43:11 +08:00

38 lines
1.4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个字符串数组 <code>words</code> ,找出并返回数组中的 <strong>第一个回文字符串</strong> 。如果不存在满足要求的字符串,返回一个 <strong>空字符串</strong><em> </em><code>""</code></p>
<p><strong>回文字符串</strong> 的定义为:如果一个字符串正着读和反着读一样,那么该字符串就是一个 <strong>回文字符串</strong></p>
<p>&nbsp;</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>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= words.length &lt;= 100</code></li>
<li><code>1 &lt;= words[i].length &lt;= 100</code></li>
<li><code>words[i]</code> 仅由小写英文字母组成</li>
</ul>