human
Give me a Python code to print all five letters to finish a croak given the following:
I found an interesting problem on https://leetcode.com/problems/minimum-number-of-frogs-croaking/:
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 croak in the given string.
A valid "croak" means a frog is printing 5 letters ‘c’, ’r’, ’o’, ’a’, ’k’ sequentially. The frogs have to print all five letters to finish a croak. If the given string is not a combination of 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.

Example 4:
Input: croakOfFrogs = "croakcroa"
Output: -1

 
Constraints:

1 <= croakOfFrogs.length <= 10^5
All characters in the string are: 'c', 'r', 'o', 'a' or 'k'.

I tried it in Python, but could not do it. Can you solve it?
assistant
#Here is Python code to print all five letters to finish a croak.

class Solution:
    def minNumberOfFrogs(self, croakOfFrogs: str) -> int:
        croaks = {'c':[], 'r':[], 'o':[], 'a':[]}
        nfrogs = 0
        icroak = 0
        curfrogs = 0
        for sound in croakOfFrogs:
            if sound == 'c':
                icroak += 1
                croaks['c'].append(icroak)
                curfrogs += 1
                nfrogs = max(curfrogs, nfrogs)
            elif sound == 'r':
                if croaks['c']:
                    croaks['r'].append(croaks['c'].pop())
                else:
                    return -1
            elif sound == 'o':
                if croaks['r']:
                    croaks['o'].append(croaks['r'].pop())
                else:
                    return -1
            elif sound == 'a':
                if croaks['o']:
                    croaks['a'].append(croaks['o'].pop())
                else:
                    return -1
            elif sound == 'k':
                if croaks['a']:
                    croaks['a'].pop()
                    curfrogs -= 1
                else:
                    return -1
            else:
                return -1
        
        for sound in croaks:
            if croaks[sound] != []:
                return -1
        
        return nfrogs