Code RoomRedundant set allocation
MediumPrep Room Coding #2097

Redundant set allocation

Code reviewCode quality & reviewMid–Senior~20 min

Review this Python aggregation over event records.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 20 min
Mark a line and say what kind of problem it is.0 findings
1from collections import defaultdict
2 
3def bucket_by_user(events):
4 buckets = defaultdict(list)
5 seen_users = set()
6 for ev in events:
7 # only count a user the first time we see them
8 if ev.user_id not in buckets:
9 seen_users.add(ev.user_id)
10 buckets[ev.user_id].append(ev)
11 return buckets, seen_users
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.