mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-08 00:41:42 +08:00
update
This commit is contained in:
39
leetcode/problem/count-the-number-of-consistent-strings.html
Normal file
39
leetcode/problem/count-the-number-of-consistent-strings.html
Normal file
@@ -0,0 +1,39 @@
|
||||
<p>You are given a string <code>allowed</code> consisting of <strong>distinct</strong> characters and an array of strings <code>words</code>. A string is <strong>consistent </strong>if all characters in the string appear in the string <code>allowed</code>.</p>
|
||||
|
||||
<p>Return<em> the number of <strong>consistent</strong> strings in the array </em><code>words</code>.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> allowed = "ab", words = ["ad","bd","aaab","baa","badab"]
|
||||
<strong>Output:</strong> 2
|
||||
<strong>Explanation:</strong> Strings "aaab" and "baa" are consistent since they only contain characters 'a' and 'b'.
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> allowed = "abc", words = ["a","b","c","ab","ac","bc","abc"]
|
||||
<strong>Output:</strong> 7
|
||||
<strong>Explanation:</strong> All strings are consistent.
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 3:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> allowed = "cad", words = ["cc","acd","b","ba","bac","bad","ac","d"]
|
||||
<strong>Output:</strong> 4
|
||||
<strong>Explanation:</strong> Strings "cc", "acd", "ac", and "d" are consistent.
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= words.length <= 10<sup>4</sup></code></li>
|
||||
<li><code>1 <= allowed.length <=<sup> </sup>26</code></li>
|
||||
<li><code>1 <= words[i].length <= 10</code></li>
|
||||
<li>The characters in <code>allowed</code> are <strong>distinct</strong>.</li>
|
||||
<li><code>words[i]</code> and <code>allowed</code> contain only lowercase English letters.</li>
|
||||
</ul>
|
Reference in New Issue
Block a user