Problem · String
Route Pattern Matcher
Problem statement
All strings in routes are registered in the order given. A route is a slash-separated path. A segment is either a literal string or a named parameter written as {name}. A parameter segment matches exactly one non-empty URL segment.
The problem statement continues
ProExamples
Example 1
routes = ["/users/{id}/pictures/{pictureId}","/health"]urls = ["/users/101/pictures/1","/health","/users/1"]return = [["/users/{id}/pictures/{pictureId}","id","101","pictureId","1"],["/health"],[]]The first URL matches the parameterized route and extracts two values. The second matches the literal route. The final URL has too few segments, so it has no match.
FastPrep Pro
Reported in 1 Google interview this weekUnlock this recently reported problem
FastPrep Pro gives you full access to interview problems reported within the last week.
- Full problem statement and constraints
- 1 more worked example, explained
- Guided hints and editorial
- Run your code on real test cases
$9/month
Pro subscription, billed yearly — or $19 month-to-month. Cancel anytime.
Free plan — 2 of 2 free unlocks used this week