We’re preparing your current view and syncing the latest data.
You have a set of tiles, where each tile has one letter printed on it. Given a string tiles, representing the letters on the tiles, return the number of possible non-empty sequences of letters you can make using the letters printed on those tiles. Each tile can only be used once in each sequence.
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
A single string tiles representing the letters on the tiles.
An integer representing the number of possible non-empty sequences of letters you can make.
1 <= tiles.length <= 7 tiles consists of uppercase English letters.
Example 1
Input
AAB
Output
8
Explanation
The sequences are A, B, AA, AB, BA, AAB, ABA, BAA.
Example 2
Input
AAABBC
Output
188
Explanation
There are 188 possible sequences that can be formed from the tiles.