Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    1419 - Minimum Number of Frogs Croaking\.

    Medium

    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: -1

    Explanation: The given string is an invalid combination of "croak**"** from different frogs.

    Constraints:

    • <code>1 <= croakOfFrogs.length <= 10<sup>5</sup></code>

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

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Integer minNumberOfFrogs(String s)
      final Unit reduce(IntArray f)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait