Maximum Number of Balloons

Given a string text, you want to use its characters to form as many copies of the word "balloon" as possible. Each character of text can be used at most once. Return the maximum number of copies that can be formed.

30:00

Maximum Number of Balloons
easy
Free written solution
Topics
Companies

Given a string text, you want to use its characters to form as many copies of the word "balloon" as possible. Each character of text can be used at most once. Return the maximum number of copies that can be formed.

Example 1:
Input: {"text":"nlaebolko"}
Output: 1
Constraints:
  • 1≤text.length≤1041 \leq \text{text.length} \leq 10^4

  • text consists of lowercase English letters only.

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"text":"nlaebolko"}

Count every letter of the 9-character text. Only b, a, l, o and n matter for "balloon".

text (0 / 9 tallied)

n
l
a
e
b
o
l
k
o

letters outside "balloon" seen so far: 0

bins: count, need per word, words this letter allows

b

0

// 1

?

a

0

// 1

?

l

0

// 2

?

o

0

// 2

?

n

0

// 1

?

Variables
VariableValue
len(text)9
DepthFunction Call
Stack empty
0/16