← Atlassian Interview Insights
Part one felt straightforward, just a hash map from path string to handler.
Start by clarifying requirements: exact matching, case sensitivity, trailing slashes, and expected time complexity. Then propose a hash map (dictionary) for O(1) average lookup, with a simple add(path, handler) and lookup(path) returning the handler or None. Discuss edge cases like duplicate registration and path normalization.
Pro tip: Mention that while a hash map is optimal for exact matching, you'd consider a trie if prefix matching or wildcards were needed later—showing you think about extensibility and trade-offs.
Ask about exact matching semantics, case sensitivity, trailing slashes, duplicate paths, and expected performance. Confirm the interface: add(path, handler) and lookup(path).
Select a hash map (e.g., dict in Python) for O(1) average-time add and lookup. Explain why it's ideal for exact matching and mention alternatives like a trie for prefix matching.
Define add() to store the handler and handle duplicates (overwrite or raise). Define lookup() to return the handler or a sentinel (e.g., None) if not found. Consider path normalization.
Write clean code with type hints and docstrings. Test with empty paths, duplicate adds, missing lookups, and paths with special characters.
Mention how the design could evolve to support wildcards, parameters, or prefix matching, and the trade-offs involved.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.
Start by clarifying the requirements: wildcard '*' matches exactly one segment, not multiple. Then propose a data structure like a trie where each node represents a segment, with special handling for wildcard nodes. Define precedence rules: exact matches take priority over wildcard matches, and if multiple wildcards match, the most specific (e.g., leftmost exact) wins.
Pro tip: Mention that wildcard matching should be deterministic and that you would document the precedence rules clearly to avoid ambiguity, which is crucial for API routing at scale.
Confirm that '*' matches exactly one segment and discuss edge cases like trailing slashes, empty segments, and multiple wildcards.
Propose a trie (prefix tree) where each node represents a path segment, with a special child for wildcard. Alternatively, a list of route patterns with a matching algorithm.
Traverse the trie segment by segment; at each step, try exact match first, then wildcard. If both fail, no match.
Exact matches always beat wildcard matches. If multiple wildcard routes match, prefer the one with more exact segments earlier in the path (leftmost specificity).
Mention performance (O(n) per lookup), memory, and how to extend to support '**' for multi-segment wildcards if needed.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.