Code Room
CodingMediumcod-g1500
Subject Bit manipulationLevel Entry–Mid~12 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

The same access-control service must display a user's permissions as human-readable names. Given a non-negative bitmask and the ordered list of permission names (the name at index i corresponds to bit i), return the list of names whose bits are set in the mask, in flag-list order. The mask may have set bits beyond the last known name — perhaps written by a newer service version — and those must be ignored. For example, mask 5 with ["read", "write", "delete"] returns ["read", "delete"].

Implement
decode_permissions(mask: int, flags: list[str]) → list[str]
Examples
in[5,["read","write","delete"]]out["read","delete"]
in[10,["r","w","x","admin"]]out["w","admin"]
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.