OAuth scope hierarchy matching
Check whether a granted OAuth scope set satisfies a required scope set with hierarchical wildcards. Scopes are colon-delimited (e.g. 'repo:read', 'admin:*'). A granted scope satisfies a required scope if they are equal, OR the granted scope ends in a '*' segment and its prefix segments are a prefix of the required scope's segments (e.g. 'admin:*' satisfies 'admin:read' and 'admin:billing:write'; '*' satisfies everything). Return True only if every required scope is satisfied by at least one granted scope.
Implement
scopes_satisfied(granted: list[str], required: list[str]) → boolExamples
in
[["repo:read","repo:write"],["repo:read"]]outtrueWhat a strong answer looks like
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.
0:00 of about 20 min
solution.py
InputExpectedGot
[["repo:read","repo:write"],["repo:read"]]truenot run yetsample