Skip to content
RED SAGSkills

Banner From Letter Tiles

You have a box of letter tiles described by the string tiles (each character is one tile). Each tile can be used at most once.

Return true if you can spell banner exactly (characters are case-sensitive and spaces are tiles too).

Example 1

Input: banner = "ship", tiles = "hips"
Output: true

Example 2

Input: banner = "aab", tiles = "abc"
Output: false
Explanation: Only one `a` tile is available.

Constraints

  • 0 <= banner.length, tiles.length <= 10^5
  • Both strings contain printable ASCII characters.
Hint 1

Count how many of each tile you have.

Hint 2

Spend one tile per banner character and fail as soon as one runs out.

Good practice for: Frontend Developer, Backend Developer, Full Stack Developer, Mobile App Developer, Automation Test Engineer, Game Developer

Run checks your code on 2 sample tests. Submit runs all 7 tests, including hidden ones, and earns points. Use console.log to debug. Python's first run can take a few seconds while it starts.