Imagine you're a data analyst for a bustling shopping mall, and you need to identify customers who window shop without making any purchases!
You have two important datasets:
- Visits Table: Records every time a customer enters the mall
- Transactions Table: Records only the visits where customers made purchases
Your task is to find customers who visited the mall but never made any transactions during those visits, and count how many times each customer had these "non-purchasing" visits.
Goal: Return a list showing each customer's ID and their count of visits without transactions, helping the mall understand customer browsing patterns.
Example: If customer 123 visited 5 times but only made purchases during 2 visits, they should appear in your result with count = 3.
Input & Output
Visualization
Time & Space Complexity
For each visit V, we scan through all transactions T to check for matches
No additional space needed beyond result storage
Constraints
- 1 โค visits.length โค 105
- transactions.length โค 105
- 1 โค visit_id, transaction_id โค 106
- 1 โค customer_id โค 104
- All visit_id and transaction_id are unique