Class Solution
java.lang.Object
g2101_2200.s2185_counting_words_with_a_given_prefix.Solution
2185 - Counting Words With a Given Prefix.<p>Easy</p>
<p>You are given an array of strings <code>words</code> and a string <code>pref</code>.</p>
<p>Return <em>the number of strings in</em> <code>words</code> <em>that contain</em> <code>pref</code> <em>as a <strong>prefix</strong></em>.</p>
<p>A <strong>prefix</strong> of a string <code>s</code> is any leading contiguous substring of <code>s</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> words = [“pay”,“<strong>at</strong>tention”,“practice”,“<strong>at</strong>tend”], <code>pref</code> = “at”</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong> The 2 strings that contain “at” as a prefix are: “<strong>at</strong>tention” and “<strong>at</strong>tend”.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> words = [“leetcode”,“win”,“loops”,“success”], <code>pref</code> = “code”</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Explanation:</strong> There are no strings that contain “code” as a prefix.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= words.length <= 100</code></li>
<li><code>1 <= words[i].length, pref.length <= 100</code></li>
<li><code>words[i]</code> and <code>pref</code> consist of lowercase English letters.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
prefixCount
-