Trains the technique from
LeetCode 44Wildcard MatchingThis 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.
An event router picks a destination by testing an incoming event's key against a subscription rule.
The key is plain text. The rule is plain text too, except that it may carry two wildcard symbols:
? stands in for exactly one character of the key.* stands in for a stretch of the key of any length, and a stretch of length zero is allowed.The router fires only on a total fit: reading the rule left to right must consume the key from its first character through its last, with nothing of the key spilling past the end of the rule and nothing of the rule left dangling once the key is used up.
Return true when rule fires on key, and false when it does not. Either text may be empty.
Example 1
The wildcard soaks up `eplo`, leaving `d` and `y` to line up with the two ends of the key.
Example 2
The first `?` takes `e` and the literals take `ploy`, but the trailing `?` still demands a character and the key has run dry.
Example 3
Each wildcard is free to stand in for a stretch of length zero, so an empty key is a total fit.
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 rule_fires(key: str, rule: str) -> bool:public boolean ruleFires(String key, String rule)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.