Code RoomJSON parsed in loop
MediumPrep Room Coding #2098

JSON parsed in loop

Code reviewAlgorithms & data structuresMid–Senior~18 min

Review this Python function that filters records out of a raw config blob.

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 18 min
Mark a line and say what kind of problem it is.0 findings
1import json
2 
3def matching_rules(raw_config_json, event_types):
4 out = []
5 for etype in event_types:
6 config = json.loads(raw_config_json) # raw_config_json is the same string every iteration
7 for rule in config["rules"]:
8 if rule["on"] == etype:
9 out.append(rule)
10 return out
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.