mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
39 lines
1.5 KiB
HTML
39 lines
1.5 KiB
HTML
|
<p>Given an array of string <code>words</code>. Return all strings in <code>words</code> which is substring of another word in <strong>any</strong> order. </p>
|
||
|
|
||
|
<p>String <code>words[i]</code> is substring of <code>words[j]</code>, if can be obtained removing some characters to left and/or right side of <code>words[j]</code>.</p>
|
||
|
|
||
|
<p> </p>
|
||
|
<p><strong>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>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>Example 3:</strong></p>
|
||
|
|
||
|
<pre>
|
||
|
<strong>Input:</strong> words = ["blue","green","bu"]
|
||
|
<strong>Output:</strong> []
|
||
|
</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>It's <strong>guaranteed</strong> that <code>words[i]</code> will be unique.</li>
|
||
|
</ul>
|