Trains the technique from
LeetCode 1684Count the Number of Consistent StringsThis 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 hand press holds type for the distinct letters listed in allowed, and it can set a label only if every letter of that label is among them. A letter may be used as often as needed.
Given the labels in words, return how many of them the press can set.
Example 1
The press holds the first six letters. "cafe", "faced" and "deface" use nothing else, while "bagged" needs a g and "zebra" needs a z.
Example 2
A letter may be repeated as often as needed, so the last three all work. Only "z" is out of reach.
Example 3
None of the labels use the single letter on hand.
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 count_consistent_strings(allowed: str, words: list[str]) -> int:public int countConsistentStrings(String allowed, String[] words)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.