Redacted Name Lookup
mediumA compliance tool ingests codenames from reports, but some queries arrive partially redacted: unknown letters are replaced with "."', and each "."may stand for any single lowercase letter."b.d"should match a stored"bad", "bed", or "bid"`.
Operations format. Your function receives one argument ops: a list of operations, each itself a list — ["add", word] stores a codename (lowercase letters only), ["search", pattern] asks whether any stored codename matches the pattern (lowercase letters and "." wildcards; lengths must match exactly). Return a list with one entry per operation: None for add, True/False for search.
Example 1
in ops = [["add", "bad"], ["add", "dad"], ["add", "mad"], ["search", "pad"], ["search", "bad"], ["search", ".ad"], ["search", "b.."]]
out [None, None, None, False, True, True, True]
".ad" matches all three stored names; "pad" matches none.
Example 2
in ops = [["add", "a"], ["search", "."], ["search", ".."]]
out [None, True, False]
A wildcard still consumes exactly one letter — lengths must agree.
Constraints
- · 1 <= len(ops) <= 2000
- · 1 <= len(word), len(pattern) <= 25
- · words are lowercase letters; patterns are lowercase letters and "."
solution.py● loading python…
test results
Hit ▶ Run to test your code against the visible cases.