All problems
0498EasyHash TableStringCounting

Kettle Signs from the Tile Tray

Tracked in this browser only
Write code

Trains the technique from

LeetCode 1189Maximum Number of Balloons

This is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.

Same function shape, different story and different numbers.

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 is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.

Python
def kettle_signs(tiles: str) -> int:
Java
public int kettleSigns(String tiles)
September 7
Apply