coding
Atlassian
Dropbox
Uber

Atlassian Coding Question: URL Router with Wildcards

Topics:
Routing
Concurrency
String Parsing
Roles:
Software Engineer
Backend Engineer
Platform Engineer
Experience:
Entry Level
Mid Level
Senior

Question Description

You are asked to build a deterministic, thread-safe URL router that maps registered path patterns to handlers and returns any captured parameters. The router matches path segments (slash-separated) and must support two segment-level constructs: a single-segment wildcard (*) that matches exactly one segment, and named parameters (like :id) that match one segment and capture its value. When multiple patterns match, the router must pick the pattern that was registered first (first-registered wins).

In an interview you'll typically walk through these stages: parsing a pattern into segments, inserting the pattern into a lookup structure, and implementing a resolve operation that walks the structure to find the best match and assemble a parameter map. You should describe and justify the data structure you choose (a segment trie or prefix tree is common), how you handle ties deterministically, and how you parse and validate incoming URLs.

Skill signals interviewers look for: robust string parsing and edge-case handling (empty segments, trailing slashes), deterministic matching logic, clear API design for register/resolve, and concurrency control that preserves registration order. For concurrency you can propose coarse-grained locking, reader-writer locks, or copy-on-write registration to allow lock-free resolves while keeping registration order consistent. Mention complexity (insert/resolve ~O(S) for S segments), memory trade-offs, and a few unit tests and edge cases you would write to prove correctness.

Common Follow-up Questions

  • How would you change the tie-breaker to prefer the most specific route (e.g., static segments over wildcards) instead of first-registered, and how does that affect data structures and complexity?
  • How would you extend the router to support a multi-segment "splat" (e.g., ** or *rest) that captures the remainder of the path, including its impact on matching and parameter semantics?
  • Describe a design that allows lock-free resolves while supporting concurrent registrations. What trade-offs does a copy-on-write approach introduce for memory and registration latency?
  • How would you benchmark and optimize this router for millions of routes and high QPS? Which metrics and micro-optimizations would you prioritize?

Related Questions

1Implement a Trie-based URL router with parameterized segments and performance constraints
2Design a deterministic route matcher that prefers longest-prefix (most-specific) match over registration order
3Build a concurrency-safe prefix tree (trie) and explain locking strategies for read-heavy workloads
4Extend a path matcher to support glob-style multi-segment wildcards and capture groups

Explore More Questions

Practice This Question with AI

Get real-time hints, detailed requirements, and insightful analysis of the question.

URL Router with Wildcards - Atlassian Coding Question | Voker