Pivot transactions by date without date libs
Company: Instacart
Role: Software Engineer
Category: Data Manipulation (SQL/Python)
Difficulty: Medium
Interview Round: Onsite
Given a stream of transaction rows (shopper_id, date_str, amount) where date_str is ISO format 'YYYY-MM-DD', produce a pivoted report for a specified 7‑day window [start_date, end_date]. For each shopper_id, output one row with columns shopper_id, d0, d1, ..., d6 where di is the sum of amount on the i‑th day offset from start_date. Constraints: rows may be unsorted and duplicate; you cannot import date/time libraries—treat date_str lexicographically for ordering and use simple arithmetic over precomputed consecutive ISO strings; assume all dates in the window exist. Specify your data structures, handling of missing days (fill with
0), and time/space complexity. Implement in any language.
Quick Answer: This question evaluates proficiency in data manipulation, string-based date handling, aggregation and pivot transformations, along with reasoning about data structures, de-duplication and missing-value filling.