Trains the technique from
LeetCode 1002Find Common CharactersThis 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.
Each player in a word game holds a rack of letter tiles. racks[i] is a string listing the tiles on the i-th rack, one lowercase letter per tile.
The umpire wants the multiset of tiles that every rack can supply at the same time. Copies count: if a letter is on one rack three times and on another rack twice, then only two copies of it can come from every rack.
Return those tiles as a list of one-letter strings, one entry per copy. Any order is accepted. Return an empty list when no letter sits on every rack.
Example 1
Letter p sits on all three racks once each, so one copy is available. Letter q sits twice, once and twice, so one copy is available. Letter r is missing from the third rack, and no other letter is on all three.
Example 2
The first rack has two e tiles but the second has only one, so one e can come from both. Letters x and z are on each rack once.
Example 3
The two racks share no letter at all, so the answer is the empty list.
The values you return may be in any order.
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 shared_tiles(racks: list[str]) -> list[str]:public List<String> sharedTiles(String[] racks)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.