1p3a Experience · Jan 2026

Movie History Friends II

Interview Experience

Movie History Friends II ### The Challenge We have a record of movies watched by different customers. The list for each customer shows the movies in the exact order they watched them. In this proble

Full Details

Movie History Friends II ### The Challenge We have a record of movies watched by different customers. The list for each customer shows the movies in the exact order they watched them. In this problem, two customers are called "friends" if they have watched at least m of the same movies within their most recent k watches. These common movies do not need to be in the same order or the same spot in the list. You are given a map connecting Customer IDs to their movie history, along with the numbers k and m (where m is less than or equal to k). Your task is to return all pairs of Customer IDs that qualify as friends. ### Important Rules -

Length Check: If a customer has watched fewer than k movies total, they cannot be friends with anyone. -

Order Does Not Matter: The matching movies can be in any position within the last k entries. -

Output Format: You can list the friend pairs in any order. However, inside each pair, you must place the smaller ID first (e.g., [1, 2], not [2, 1]). -

No Duplicates: Each pair of friends should be listed only once. ### Walkthrough Examples

Case 1:

Input: history = {1: ["A", "B", "C", "D"], 2: ["X", "D", "B", "A"], 3: ["P", "Q", "R", "S"]}, k = 3, m = 2

Output: [[1, 2]]

Breakdown: *

Customer 1: The last 3 movies are ["B", "C", "D"]. *

Customer 2: The last 3 movies are ["D", "B", "A"]. *

Result: They both watched "B" and "D". That is 2 common movies. Since m is 2, this is enough to be friends. *

Customer 3: Their movies are completely different, so they have no friends here.

Case 2:

Input: history = {1: ["A", "B", "C"], 2: ["C", "B", "A"], 3: ["A", "B", "C"]}, k = 3, m = 3

Output: [[1, 2], [1, 3], [2, 3]]

Breakdown: All customers watched "A", "B", and "C" in their last 3 slots, just in different orders. Because they all share 3 movies, every possible pair is a friend pair.

Case 3:

Input: history = {1: ["A", "B", "C"], 2: ["D", "E", "F"]}, k = 3, m = 1

Output: []

Breakdown: There are no common movies between the two customers. Therefore, the result is an empty list. ### Data Constraints - 1 <= number of customers <= 1000 - 1 <= m <= k <= 100 - 0 <= history[i].length <= 1000 - Movie IDs are strings

About This Question

This is a candidate experience report from a netflix interview for a swe role reported in 2025.

It covers the following topics: Strings .

Topics