Class Solution
java.lang.Object
g2201_2300.s2255_count_prefixes_of_a_given_string.Solution
2255 - Count Prefixes of a Given String.<p>Easy</p>
<p>You are given a string array <code>words</code> and a string <code>s</code>, where <code>words[i]</code> and <code>s</code> comprise only of <strong>lowercase English letters</strong>.</p>
<p>Return <em>the <strong>number of strings</strong> in</em> <code>words</code> <em>that are a <strong>prefix</strong> of</em> <code>s</code>.</p>
<p>A <strong>prefix</strong> of a string is a substring that occurs at the beginning of the string. A <strong>substring</strong> is a contiguous sequence of characters within a string.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> words = [“a”,“b”,“c”,“ab”,“bc”,“abc”], s = “abc”</p>
<p><strong>Output:</strong> 3</p>
<p><strong>Explanation:</strong></p>
<p>The strings in words which are a prefix of s = “abc” are:</p>
<p>“a”, “ab”, and “abc”.</p>
<p>Thus the number of strings in words which are a prefix of s is 3.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> words = [“a”,“a”], s = “aa”</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong></p>
<p>Both of the strings are a prefix of s.</p>
<p>Note that the same string can occur multiple times in words, and it should be counted each time.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= words.length <= 1000</code></li>
<li><code>1 <= words[i].length, s.length <= 10</code></li>
<li><code>words[i]</code> and <code>s</code> consist of lowercase English letters <strong>only</strong>.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
countPrefixes
-