Code RoomConfiguration word bit changes
EasyPrep Room Coding #4751

Configuration word bit changes

CodingAlgorithms & data structuresEntry–Mid~14 min

A rollout service ships device settings as one 32 bit configuration word. Bit i of that word, counting the least significant bit as bit 0, holds the flag named at position i of flag_names. Positions at or beyond the length of flag_names are reserved for other subsystems and must be ignored, even when their bits are set. Given the word a device carried before a rollout and the word it carries after, return one entry for every named flag whose bit changed, ordered by ascending bit position. Write an entry as the flag name, then a colon, then on when that bit is set in after, or off when the bit was set in before and is clear in after. Flags left alone contribute nothing, so an unchanged word returns an empty list.

Implement
flag_rollout_changes(flag_names: list[str], before: int, after: int) → list[str]
Examples
in[["dark_mode","beta_search","new_editor"],1,6]out["dark_mode:off","beta_search:on","new_editor:on"]
in[["autosave","telemetry"],3,3]out[]
in[["autosave"],0,9]out["autosave:on"]
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 14 min
InputExpectedGot
[["dark_mode","beta_search","new_editor"],1,6]["dark_mode:off","beta_search:on","new_editor:on"]not run yetsample
[["autosave","telemetry"],3,3][]not run yetsample
[["autosave"],0,9]["autosave:on"]not run yetsample