First-time buyers
A shop compares today's buyers against its history. Given the list of customer IDs that have ever purchased before and the list of IDs that purchased today (repeats possible in both), return the IDs of today's first-time buyers — those that appear today but nowhere in the history — as an ascending list without duplicates. Example: history [1, 2, 3], today [3, 4, 4, 5] gives [4, 5].
Implement
first_time_buyers(history: list[int], today: list[int]) → list[int]Examples
in
[[1,2,3],[3,4,4,5]]out[4,5]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.
0:00 of about 11 min
solution.py
InputExpectedGot
[[1,2,3],[3,4,4,5]][4,5]not run yetsample