#1079
Letter Tile Possibilities
pupil · 405 · lc medium +24 · verified · 83.5% accepted · 3,137 likes · top 95%
Description
You have n tiles where each tile tiles[i] has a printed letter. Return the number of distinct non-empty sequences of letters that can be formed using some or all of the tiles.
Example 1:
Input: tiles = "AAB"
Output: 8
Explanation: The possible sequences are "A", "B", "AA", "AB", "BA", "AAB", "ABA", "BAA".
Example 2:
Input: tiles = "AAABBC"
Output: 188
Example 3:
Input: tiles = "V"
Output: 1
Code
1
2
3