1189. Maximum Number of Balloons

1189. Maximum Number of Balloons

class Solution:
    def maxNumberOfBalloons(self, text: str) -> int:
        
        target = "balloon"
        table = defaultdict(int)
            
        for c in text:
            table[c] += 1
        
        counter = Counter(target)
        
        mix = defaultdict(int)
        
        for key, val in counter.items():
            if key not in table:
                return 0
            else:
                mix[key] += table[key] / val
        
        res = float('inf')
        for key, val in mix.items():
            res = min(res, mix[key])
            
        
        return int(res)