Maximum Number of Balloons
Real-world version: Kettle Signs from the Tile TrayThe statement here is our own: the same inputs, outputs and technique.
A sign shop keeps loose letter tiles in one tray. The string tiles gives the letter printed on each tile in the tray, one lowercase letter per tile.
A finished sign spells the word kettle, so laying out one sign takes a k tile, two e tiles, two t tiles and an l tile. A tile can only be laid into one sign: once it is used it is gone for the rest of the run, and tiles printed with any other letter are no help at all.
Return how many finished signs the shop can lay out from the tray it has.
Examples
Example 1
- Input
- tiles = "ttlleekkeettll"
- Output
- 2
The tray holds two k tiles, four e tiles, four t tiles and four l tiles. Two signs use two k, four e, four t and two l tiles, which the tray covers, and two l tiles are left over.
Example 2
- Input
- tiles = "kkeeeetttlll"
- Output
- 1
One sign takes a k, two e, two t and an l tile. That leaves a k, two e, a t and two l tiles sitting unused in the tray.
Example 3
- Input
- tiles = "settlement"
- Output
- 0
There is no k tile anywhere in the tray, so no sign can be laid out.
Constraints
- 1 <= tiles.length <= 10^4
- tiles consists of lowercase English letters only
The signature
The editor starts with this. It matches the parent problem's shape, so a solution that works here works on a standard judge unchanged.
def kettle_signs(tiles: str) -> int:public int kettleSigns(String tiles)Checking your plan…
How this problem was checked
- Passed: Reference solution run against 11 test cases: 11 passed
- Passed: 3 worked examples confirmed by running the code
- Passed: 0 eight-word sequences shared with the parent problem's text
- Passed: Agrees with an independent brute-force solution on random inputs
- Passed: Test set shown to catch deliberately broken solutions
- Passed: Reviewed by a separate quality pass
- Passed: Function arity matches the parent problem's
More on the same topics
- First Unique Character in a StringReal-world version: First Solo StopEasy
- Ransom NoteReal-world version: Spell It With TilesEasy
- Find Words That Can Be Formed by CharactersReal-world version: Signs Spellable From A Tile TrayEasy
- Substrings of Size Three with Distinct CharactersReal-world version: Three Clean Pigment WindowsEasy