Level: Mid-Level
Round: Phone Screen · Type: Coding · Difficulty: 3/10 · Duration: 60 min · Interviewer: Neutral
Topics: Arrays, Sliding Window
Location: Los Gatos, CA
Interview date: 2024-12-31
Got offer: False
I had a technical phone interview where I was asked to find duplicate numbers in a given series of viewing IDs. The interviewer was great, but technical difficulties with CodeSignal led to an unsuccessful interview.
The coding question I got involved finding duplicate numbers:
L1: Given a series of viewing IDs, return True if there are any duplicate views, otherwise return False. Example: [4, 5, 100, 200, 5] -> True.
L2: Return True if there are any duplicate views within the most recent K window. This requires using a sliding window.
L3: Given an ID range T, consider two IDs to belong to the same series if their distance is less than or equal to T. Return True if any two IDs meet this condition. For example, with T=4, [1, 5, 100] -> True, but with T=3, it returns False.
`python def has_duplicates(ids): seen = set() for id in ids: if id in seen: return True seen.add(id) return False
def has_duplicates_sliding_window(ids, k): if not ids or k <= 0: return False window = set() for i in range(len(ids)): if i > k: window.remove(ids[i - k - 1]) if ids[i] in window: return True window.add(ids[i]) return False
def has_close_ids(ids, t): for i in range(len(ids)): for j in range(i + 1, len(ids)): if abs(ids[i] - ids[j]) <= t: return True return False `