Leetcode 1297 Solution
This article provides solution to leetcode question 1297 (maximum-number-of-balloons)
Access this page by simply typing in "lcs 1297" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/maximum-number-of-balloons
Solution
class Solution:
def maxNumberOfBalloons(self, text: str) -> int:
m = collections.defaultdict(int)
for ch in text:
m[ch] += 1
cnt = 10000
cnt = min(cnt, m["b"])
cnt = min(cnt, m["a"])
cnt = min(cnt, m["l"] // 2)
cnt = min(cnt, m["o"] // 2)
cnt = min(cnt, m["n"])
return cnt