Minimum Number of Frogs Croaking
You are given the string croakOfFrogs, which represents a combination of the string "croak" from different frogs. Multiple frogs can croak at the same time, so multiple "croak" strings may be mixed together.
Return the minimum number of different frogs needed to finish all the croaks in the given string.
A valid "croak" means a frog prints the five letters 'c', 'r', 'o', 'a', and 'k' sequentially. Each frog has to print all five letters to finish a croak. If the given string is not a combination of valid "croak" strings, return -1.
Example 1
Input
croakOfFrogs = "croakcroak"Output
1One frog yells "croak" twice.
Example 2
Input
croakOfFrogs = "crcoakroak"Output
2The minimum number of frogs is two.
Constraints
- 1 <= croakOfFrogs.length <= 10^5
- croakOfFrogs is either 'c', 'r', 'o', 'a', or 'k'.