Prefix Matcher
Asked at Datadog
Reported by the problem's creator, not verified
Implement the class PrefixMatcher. add(prefix) stores a prefix, and match(strings) reports which of the given strings begin with at least one stored prefix.
Examples
Example 1
Input: init =
[], operations =[["add",["ab"]],["add",["xyz"]],["match",[["abc","xy","xyzzy","ba","ab"]]]]Output:
[null,null,["abc","xyzzy","ab"]]Explanation:
abcandabbegin withab, andxyzzybegins withxyz.xyis shorter thanxyz, so it does not match, andbadoes not begin withab.
Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.