LeetCode solutions

1297. Maximum Number of Balloons

My accepted Python solution to LeetCode problem 1297, Maximum Number of Balloons, running in 0ms.

  • Difficulty: Easy
  • Python
  • Runtime 0ms
  • Memory 17.4MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 0ms, memory 17.4MB, accepted 2025-12-30.

python
class Solution:
    def maxNumberOfBalloons(self, text: str) -> int:
        from collections import Counter
        count = Counter(text)
        # balloon needs: b=1, a=1, l=2, o=2, n=1
        return min(
            count['b'],
            count['a'],
            count['l'] // 2,
            count['o'] // 2,
            count['n']
        )

Source