Routing Prefix Dashboard
Preview mode. Log in to edit, run, submit, and save progress.
Routing Prefix Dashboard
A routing dashboard stores many lowercase service names. Analysts ask multiple prefix queries against the same catalog. For each requested prefix, determine how many catalog names begin with that exact prefix. The queries must be answered independently and returned in the same order in which they were requested. Input Format: You are given an array words containing catalog names and an array prefixes containing query prefixes. Output Format: Return an integer array where answer[i] is the number of words that start with prefixes[i].
Examples
words = ["pay", "payroll", "paint", "pilot", "desk"] prefixes = ["pa", "pay", "pi"]
3 2 1
Explanation: Prefix counts are pa:3, pay:2, pi:1. Therefore the dashboard prints 3 2 1.
Approach hint
The same catalog is queried many times.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.