Loading...
Loading...
You are given four lists of the same length: customers, providers, items, and days. Each index i describes one record: customer customers[i] received item items[i] from provider providers[i] on day days[i]. The records are sorted by day, so days is non-decreasing.
A customer and an item form a qualifying pair when two records exist such that:
30.Return every qualifying pair once, as a single string made of the customer, one space, and the item, for example "P1 Atorvastatin". Return the qualifying pairs in any order. If no pair qualifies, return an empty list.
Input: customers = ["P1","P1","P2","P2"], providers = ["D1","D2","D3","D4"], items = ["Atorvastatin","Atorvastatin","Metformin","Metformin"], days = [10,36,60,84]
Output: ["P1 Atorvastatin","P2 Metformin"]
Explanation: Customer P1 received Atorvastatin from D1 on day 10 and from D2 on day 36. The
providers differ and the days differ by 26, so "P1 Atorvastatin" qualifies. Customer P2
received Metformin from D3 on day 60 and from D4 on day 84, which differ by 24, so
"P2 Metformin" qualifies too.
Input: customers = ["A","A","A"], providers = ["X","X","X"], items = ["pen","pen","pen"], days = [1,2,3]
Output: []
Explanation: All three records come from provider X. No two records have different
providers, so nothing qualifies.
Input: customers = ["A","B","A","B"], providers = ["X","X","Y","Y"], items = ["pen","pen","pen","pen"], days = [0,0,30,31]
Output: ["A pen"]
Explanation: Customer A received pen from X on day 0 and from Y on day 30. The days differ by
exactly 30, which is within the window, so "A pen" qualifies. Customer B received pen from X
on day 0 and from Y on day 31. The days differ by 31, so "B pen" does not qualify.
customers, providers, items, and days all have the same length ndays[i] ≤109days[i] ≤ days[i + 1] for every valid i30 days.