Letter Tile Possibilities

You have n tiles, where each tile has one letter tiles[i] printed on it.

Return the number of possible non-empty sequences of letters you can make using the letters printed on those tiles.

Example 1
Inputtiles = "AAB"
Output8
The possible sequences are "A", "B", "AA", "AB", "BA", "AAB", "ABA", and "BAA".
Example 2
Inputtiles = "AAABBC"
Output188
There are 188 possible non-empty sequences that can be made from the letters in tiles.

Constraints

  • 1 <= tiles.length <= 7
  • tiles consists of uppercase English letters.

Asked at 5 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate