1419. Minimum Number of Frogs Croaking Medium
1/**
2 * [1419] Minimum Number of Frogs Croaking
3 *
4 * 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.
5 * Return the minimum number of different frogs to finish all the croaks in the given string.
6 * 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.
7 *
8 * Example 1:
9 *
10 * Input: croakOfFrogs = "croakcroak"
11 * Output: 1
12 * Explanation: One frog yelling "croak" twice.
13 *
14 * Example 2:
15 *
16 * Input: croakOfFrogs = "crcoakroak"
17 * Output: 2
18 * Explanation: The minimum number of frogs is two.
19 * The first frog could yell "crcoakroak".
20 * The second frog could yell later "crcoakroak".
21 *
22 * Example 3:
23 *
24 * Input: croakOfFrogs = "croakcrook"
25 * Output: -1
26 * Explanation: The given string is an invalid combination of "croak" from different frogs.
27 *
28 *
29 * Constraints:
30 *
31 * 1 <= croakOfFrogs.length <= 10^5
32 * croakOfFrogs is either 'c', 'r', 'o', 'a', or 'k'.
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/minimum-number-of-frogs-croaking/
38// discuss: https://leetcode.com/problems/minimum-number-of-frogs-croaking/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43 pub fn min_number_of_frogs(croak_of_frogs: String) -> i32 {
44 0
45 }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_1419() {
56 }
57}
58
Back
© 2025 bowen.ge All Rights Reserved.