Question
Given a list of URL paths, compute their longest common path prefix for routing purposes, matching on whole path segments (not characters). Each path starts with '/'. Return the common prefix as a path string starting with '/' (e.g. '/api/v1'); if the only common ancestor is the root, return '/'. An empty list returns '/'. A single path returns that path.
common_path_prefix(paths: list[str]) → str[["/api/v1/users","/api/v1/orders","/api/v1/users/5"]]out"/api/v1"State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.