Code RoomParse audit events
EasyPrep Room Coding #4817

Parse audit events

CodingSecurityAlgorithms & data structuresEntry–Mid~15 min

A compliance job reviews the audit trail an admin console wrote before that trail is handed to the auditors. Each event is one string of key=value pairs joined by semicolons, for example actor=alice;action=delete. Keys and values may carry surrounding spaces, which are trimmed away, and a field counts as missing when no pair holds that key or when its value is empty once trimmed. When one event repeats a key, only the first pair carrying that key is read. A piece with no equals sign is malformed and holds nothing, and a value may itself contain an equals sign, since only the first one separates. Return one entry for every event missing at least one of the required fields, keeping events in the order given, written as the event's 1-based position, a colon, then the names of its missing fields joined by commas in the order those names appear in required. A name listed twice in required counts once.

Implement
audit_gap_report(events: list[str], required: list[str]) → list[str]
Examples
in[["actor=alice;action=delete;target=repo-7","actor=bob;action=delete","action=login;actor= ;target=console"],["actor","action","target"]]out["2:target","3:actor"]
in[["actor=;actor=carol;action=view;target=doc"],["actor","action"]]out["1:actor"]
in[["actor=hana;action=purge;target=logs;ts=2026-08-04","ts=2026-08-04;action=purge","actor= ;action= ;ts="],["ts","actor","action"]]out["2:actor","3:ts,actor,action"]
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 15 min
InputExpectedGot
[["actor=alice;action=delete;target=repo-7","actor=bob;action=delete","action=login;actor= ;target=console"],["actor","action","target"]]["2:target","3:actor"]not run yetsample
[["actor=;actor=carol;action=view;target=doc"],["actor","action"]]["1:actor"]not run yetsample
[["actor=hana;action=purge;target=logs;ts=2026-08-04","ts=2026-08-04;action=purge","actor= ;action= ;ts="],["ts","actor","action"]]["2:actor","3:ts,actor,action"]not run yetsample