1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/数青蛙 [minimum-number-of-frogs-croaking].html
2022-03-29 12:43:11 +08:00

43 lines
1.7 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个字符串 <code>croakOfFrogs</code>,它表示不同青蛙发出的蛙鸣声(字符串 <code>"croak"</code> )的组合。由于同一时间可以有多只青蛙呱呱作响,所以&nbsp;<code>croakOfFrogs</code> 中会混合多个 <code>“croak”</code> <em></em></p>
<p>请你返回模拟字符串中所有蛙鸣所需不同青蛙的最少数目。</p>
<p>要想发出蛙鸣 "croak",青蛙必须 <strong>依序</strong> 输出 <code>c, r, o, a, k</code> 这 5 个字母。如果没有输出全部五个字母,那么它就不会发出声音。如果字符串 <code>croakOfFrogs</code> 不是由若干有效的 "croak" 字符混合而成,请返回 <code>-1</code></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>croakOfFrogs = "croakcroak"
<strong>输出:</strong>1
<strong>解释:</strong>一只青蛙 “呱呱” 两次
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>croakOfFrogs = "crcoakroak"
<strong>输出:</strong>2
<strong>解释:</strong>最少需要两只青蛙,“呱呱” 声用黑体标注
第一只青蛙 "<strong>cr</strong>c<strong>oak</strong>roak"
第二只青蛙 "cr<strong>c</strong>oak<strong>roak</strong>"
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>croakOfFrogs = "croakcrook"
<strong>输出:</strong>-1
<strong>解释:</strong>给出的字符串不是 "croak<strong>"</strong> 的有效组合。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= croakOfFrogs.length &lt;= 10<sup>5</sup></code></li>
<li>字符串中的字符只有 <code>'c'</code>, <code>'r'</code>, <code>'o'</code>, <code>'a'</code> 或者 <code>'k'</code></li>
</ul>