Trains the technique from
LeetCode 1079Letter Tile PossibilitiesThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A bag holds tiles, each stamped with one uppercase letter, given by tiles. Tiles may be laid out in a row in any order, using anywhere from one of them up to all of them.
Return how many different non-empty strings can be laid out. Two rows count as the same string when they read alike.
Example 1
The rows are A, B, AB and BA.
Example 2
The two tiles read alike, so the only rows are A and AA.
Example 3
Three rows of one tile, six of two tiles and six of all three.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def num_tile_possibilities(tiles: str) -> int:public int numTilePossibilities(String tiles)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.