Code Room
CodingMediumcod-g1006
Subject AuthorizationLevel Mid–Senior~18 minCommon in Security interviewsIndustries Software development, IT services

Question

Implement an RBAC permission evaluator. A user holds a list of `roles`; `role_permissions` maps each role name to a list of permission strings it grants. Given the user's roles, the role-permission map, and a `required` permission, return True if ANY of the user's roles grants the required permission. Unknown roles (not present in the map) grant nothing. A user with no roles is granted nothing.

Implement
has_permission(roles: list[str], role_permissions: dict, required: str) → bool
Examples
in[["admin"],{"admin":["read","write","delete"],"editor":["read","write"],"viewer":["read"]},"delete"]outtrue
What 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.

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.

Run or narrate your approach, then ask the coach.