Solved LeetCode program · 873 of 1,000
#1189 · Maximum Number of Balloons
Original English source
The word is "loonbalxballpoon". The last is the last position of word. The bees is 0. The ayes is 0. The elles is 0. The ohs is 0. The ens is 0.
For every spot from 0 to last.
The piece is the slice of word from spot to spot plus 1. If piece matches "b", add 1 to bees. If piece matches "a", add 1 to ayes. If piece matches "l", add 1 to elles. If piece matches "o", add 1 to ohs. If piece matches "n", add 1 to ens.
Set elles to elles divided by 2. Set ohs to ohs divided by 2. The answer is bees. If ayes is less than answer, set answer to ayes. If elles is less than answer, set answer to elles. If ohs is less than answer, set answer to ohs. If ens is less than answer, set answer to ens.
Show answer.
Expected stdout
2