Code Room
CodingMediumcod-g1260
Subject HashingLevel Entry–Mid~15 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

A music service wants the songs that every one of its editorial playlists agrees on. Given a list of playlists, each a list of integer song ids (a playlist may repeat an id), return the ids that appear in every playlist, sorted ascending. If the outer list is empty, return an empty list; a single playlist returns its distinct ids sorted. For example, [[1, 2, 3], [2, 3, 4], [3, 2, 9]] returns [2, 3]. Intersecting lists pairwise with repeated scans is the slow path — count memberships instead.

Implement
common_to_all(playlists: list[list[int]]) → list[int]
Examples
in[[[1,2,3],[2,3,4],[3,2,9]]]out[2,3]
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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.