java.lang.Object
g1901_2000.s1961_check_if_string_is_a_prefix_of_array.Solution

public class Solution extends Object
1961 - Check If String Is a Prefix of Array.<p>Easy</p> <p>Given a string <code>s</code> and an array of strings <code>words</code>, determine whether <code>s</code> is a <strong>prefix string</strong> of <code>words</code>.</p> <p>A string <code>s</code> is a <strong>prefix string</strong> of <code>words</code> if <code>s</code> can be made by concatenating the first <code>k</code> strings in <code>words</code> for some <strong>positive</strong> <code>k</code> no larger than <code>words.length</code>.</p> <p>Return <code>true</code> <em>if</em> <code>s</code> <em>is a <strong>prefix string</strong> of</em> <code>words</code><em>, or</em> <code>false</code> <em>otherwise</em>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;iloveleetcode&rdquo;, words = [&ldquo;i&rdquo;,&ldquo;love&rdquo;,&ldquo;leetcode&rdquo;,&ldquo;apples&rdquo;]</p> <p><strong>Output:</strong> true</p> <p><strong>Explanation:</strong> s can be made by concatenating &ldquo;i&rdquo;, &ldquo;love&rdquo;, and &ldquo;leetcode&rdquo; together.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;iloveleetcode&rdquo;, words = [&ldquo;apples&rdquo;,&ldquo;i&rdquo;,&ldquo;love&rdquo;,&ldquo;leetcode&rdquo;]</p> <p><strong>Output:</strong> false</p> <p><strong>Explanation:</strong> It is impossible to make s using a prefix of arr.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= words.length <= 100</code></li> <li><code>1 <= words[i].length <= 20</code></li> <li><code>1 <= s.length <= 1000</code></li> <li><code>words[i]</code> and <code>s</code> consist of only lowercase English letters.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • isPrefixString

      public boolean isPrefixString(String s, String[] words)