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.

30:00

Letter Tile Possibilities
medium
Free written solution
Topics
Companies

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:
Input: {"tiles":"AAB"}
Output: 8
Constraints:
  • 1≤tiles.length≤71 \leq \text{tiles.length} \leq 7

  • tiles consists of uppercase English letters.

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"tiles":"AAB"}

Count the tiles: A:2 B:1. Tiles with the same letter are interchangeable, so the search picks a letter, not a tile.

rack (tiles left per letter)

A
A

A: 2/2

B

B: 1/1

current sequence (depth 0)

sequences counted

0

amber: tile takenrose: tile put backgreen: newest sequence
Variables
VariableValue
tiles"AAB"
countA:2 B:1
DepthFunction Call
Stack empty
0/17