Code RoomCommon tags nested loop
MediumPrep Room Coding #1713

Common tags nested loop

Code reviewCode quality & reviewMid–Senior~25 min

Review this Python function that finds tags shared between two feeds.

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 25 min
Mark a line and say what kind of problem it is.0 findings
1def common_tags(posts_a, posts_b):
2 # posts_a, posts_b: lists of Post objects, each with a .tag string
3 common = []
4 for a in posts_a:
5 for b in posts_b:
6 if a.tag == b.tag and a.tag not in common:
7 common.append(a.tag)
8 return common
9 
10def report(feed_a, feed_b):
11 shared = common_tags(feed_a, feed_b)
12 return f"{len(shared)} shared tags: {', '.join(shared)}"
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.