五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

LeetCode 1419. Minimum Number of Frogs Croaking

2023-05-06 12:40 作者:您是打尖兒還是住店呢  | 我要投稿

You are given the string?croakOfFrogs, which represents a combination of the string?"croak"?from different frogs, that is, multiple frogs can croak at the same time, so multiple?"croak"?are mixed.

Return the minimum number of?different?frogs to finish all the croaks in the given string.

A valid?"croak"?means a frog is printing five letters?'c',?'r',?'o',?'a', and?'k'?sequentially. The frogs have to print all five letters to finish a croak. If the given string is not a combination of a valid?"croak"?return?-1.

?

Example 1:

Input: croakOfFrogs = "croakcroak"Output: 1 Explanation: One frog yelling "croak" twice.

Example 2:

Input: croakOfFrogs = "crcoakroak"Output: 2 Explanation: The minimum number of frogs is two. The first frog could yell "crcoakroak". The second frog could yell later "crcoakroak".

Example 3:

Input: croakOfFrogs = "croakcrook"Output: -1Explanation: The given string is an invalid combination of "croak" from different frogs.

?

Constraints:

  • 1 <= croakOfFrogs.length <= 105

  • croakOfFrogs?is either?'c',?'r',?'o',?'a', or?'k'.

都有點(diǎn)快抑郁了,,,

1:判斷是否是按照順序,用hashmap去每次循環(huán)的時(shí)候判斷一下,(這個(gè)地方一直沒(méi)想到)

2:當(dāng)有'c'的時(shí)候 frog++,當(dāng)出現(xiàn)‘k’的時(shí)候 frog--;

3:所以就是要把這2個(gè)問(wèn)題分開(kāi)去處理,一開(kāi)始光想著一下子去處理了。所以走了不少的彎路;

4:最后就是res要max去判斷每個(gè)。

下面是代碼:

都是經(jīng)驗(yàn)教訓(xùn)啊。。。


Runtime93 ms

Beats

6.17%

Memory43.4 MB

Beats

22.14%


LeetCode 1419. Minimum Number of Frogs Croaking的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
石渠县| 扎兰屯市| 克山县| 青河县| 鞍山市| 巴中市| 关岭| 迭部县| 民乐县| 木里| 苍溪县| 全南县| 磐石市| 台中县| 雷州市| 潍坊市| 罗山县| 浦城县| 白山市| 东乌珠穆沁旗| 云龙县| 上饶市| 邛崃市| 龙江县| 江津市| 贵溪市| 澎湖县| 乌拉特后旗| 丰宁| 徐州市| 弥渡县| 桃园市| 太原市| 富宁县| 依兰县| 得荣县| 当雄县| 独山县| 调兵山市| 兴业县| 伊宁县|