This question evaluates proficiency with trie-based data structures, string/segment pattern matching, and API design for route management (addRoute, removeRoute, match), including support for single-segment wildcards, precedence among overlapping patterns, and edge cases such as leading/trailing slashes and duplicate routes.
Implement a URL routing matcher that supports adding route patterns and matching request paths. Use a trie as the core data structure. Support static segments (e.g., /a/b/c) and a single-segment wildcard as in /a/*/c. Design APIs addRoute(pattern, handler), removeRoute(pattern), and match(path) -> matchedHandler (and the matched pattern). Define precedence rules when multiple patterns could match (e.g., prefer more specific over wildcard). Analyze time and space complexity and provide unit tests covering edge cases such as leading/trailing slashes, duplicate routes, and overlapping wildcard patterns.