mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
47 lines
1.5 KiB
HTML
47 lines
1.5 KiB
HTML
<p>给定一个由唯一字符串构成的 <strong>0 索引 </strong>数组 <code>words</code> 。</p>
|
||
|
||
<p><strong>回文对</strong> 是一对整数 <code>(i, j)</code> ,满足以下条件:</p>
|
||
|
||
<ul>
|
||
<li><code>0 <= i, j < words.length</code>,</li>
|
||
<li><code>i != j</code> ,并且</li>
|
||
<li><code>words[i] + words[j]</code>(两个字符串的连接)是一个回文。</li>
|
||
</ul>
|
||
|
||
<p>返回一个数组,它包含 <code>words</code> 中所有满足 <strong>回文对</strong> 条件的字符串。</p>
|
||
|
||
<p>你必须设计一个时间复杂度为 <code>O(sum of words[i].length)</code> 的算法。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>words = ["abcd","dcba","lls","s","sssll"]
|
||
<strong>输出:</strong>[[0,1],[1,0],[3,2],[2,4]]
|
||
<strong>解释:</strong>可拼接成的回文串为 <code>["dcbaabcd","abcddcba","slls","llssssll"]</code>
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>words = ["bat","tab","cat"]
|
||
<strong>输出:</strong>[[0,1],[1,0]]
|
||
<strong>解释:</strong>可拼接成的回文串为 <code>["battab","tabbat"]</code></pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>words = ["a",""]
|
||
<strong>输出:</strong>[[0,1],[1,0]]
|
||
</pre>
|
||
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= words.length <= 5000</code></li>
|
||
<li><code>0 <= words[i].length <= 300</code></li>
|
||
<li><code>words[i]</code> 由小写英文字母组成</li>
|
||
</ul>
|