mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
40 lines
1.6 KiB
HTML
40 lines
1.6 KiB
HTML
<p>Given an array of string <code>words</code>, return <em>all strings in </em><code>words</code><em> that is a <strong>substring</strong> of another word</em>. You can return the answer in <strong>any order</strong>.</p>
|
|
|
|
<p>A <strong>substring</strong> is a contiguous sequence of characters within a string</p>
|
|
|
|
<p> </p>
|
|
<p><strong class="example">Example 1:</strong></p>
|
|
|
|
<pre>
|
|
<strong>Input:</strong> words = ["mass","as","hero","superhero"]
|
|
<strong>Output:</strong> ["as","hero"]
|
|
<strong>Explanation:</strong> "as" is substring of "mass" and "hero" is substring of "superhero".
|
|
["hero","as"] is also a valid answer.
|
|
</pre>
|
|
|
|
<p><strong class="example">Example 2:</strong></p>
|
|
|
|
<pre>
|
|
<strong>Input:</strong> words = ["leetcode","et","code"]
|
|
<strong>Output:</strong> ["et","code"]
|
|
<strong>Explanation:</strong> "et", "code" are substring of "leetcode".
|
|
</pre>
|
|
|
|
<p><strong class="example">Example 3:</strong></p>
|
|
|
|
<pre>
|
|
<strong>Input:</strong> words = ["blue","green","bu"]
|
|
<strong>Output:</strong> []
|
|
<strong>Explanation:</strong> No string of words is substring of another string.
|
|
</pre>
|
|
|
|
<p> </p>
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>1 <= words.length <= 100</code></li>
|
|
<li><code>1 <= words[i].length <= 30</code></li>
|
|
<li><code>words[i]</code> contains only lowercase English letters.</li>
|
|
<li>All the strings of <code>words</code> are <strong>unique</strong>.</li>
|
|
</ul>
|