java.lang.Object
g1401_1500.s1408_string_matching_in_an_array.Solution

public class Solution extends Object
1408 - String Matching in an Array.<p>Easy</p> <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><strong>Example 1:</strong></p> <p><strong>Input:</strong> words = [&ldquo;mass&rdquo;,&ldquo;as&rdquo;,&ldquo;hero&rdquo;,&ldquo;superhero&rdquo;]</p> <p><strong>Output:</strong> [&ldquo;as&rdquo;,&ldquo;hero&rdquo;]</p> <p><strong>Explanation:</strong> &ldquo;as&rdquo; is substring of &ldquo;mass&rdquo; and &ldquo;hero&rdquo; is substring of &ldquo;superhero&rdquo;. [&ldquo;hero&rdquo;,&ldquo;as&rdquo;] is also a valid answer.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> words = [&ldquo;leetcode&rdquo;,&ldquo;et&rdquo;,&ldquo;code&rdquo;]</p> <p><strong>Output:</strong> [&ldquo;et&rdquo;,&ldquo;code&rdquo;]</p> <p><strong>Explanation:</strong> &ldquo;et&rdquo;, &ldquo;code&rdquo; are substring of &ldquo;leetcode&rdquo;.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> words = [&ldquo;blue&rdquo;,&ldquo;green&rdquo;,&ldquo;bu&rdquo;]</p> <p><strong>Output:</strong> []</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&rsquo;s <strong>guaranteed</strong> that <code>words[i]</code> will be unique.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details