Code RoomPermission bitmask encoder
EasyPrep Room Coding #703

Permission bitmask encoder

CodingAlgorithms & data structuresEntry–Mid~12 min

An access-control service stores each user's permissions as one integer bitmask. You are given the ordered list of permission names for a resource — the name at index i corresponds to bit i — and the list of names granted to a user (each granted name appears in the flag list; no duplicates). Return the bitmask encoding the grant. For example, with flags ["read", "write", "delete"] and granted ["read", "delete"], bits 0 and 2 are set, so return 5.

Implement
encode_permissions(flags: list[str], granted: list[str]) → int
Examples
in[["read","write","delete"],["read","delete"]]out5
in[["r","w","x","admin"],["admin","w"]]out10
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.

0:00 of about 12 min
InputExpectedGot
[["read","write","delete"],["read","delete"]]5not run yetsample
[["r","w","x","admin"],["admin","w"]]10not run yetsample