RBAC permission evaluator
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) → boolExamples
in
[["admin"],{"admin":["read","write","delete"],"editor":["read","write"],"viewer":["read"]},"delete"]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 18 min
solution.py
InputExpectedGot
[["admin"],{"admin":["read","write","delete"],"editor":["read","write"],"viewer":["read"]},"delete"]truenot run yetsample