Implement Binary Search for Policy Violation Logs
Company: Pinterest
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Onsite
Overview: This question evaluates understanding of algorithmic search and data manipulation skills, specifically applying binary search over date-ordered logs and composing efficient queries using SQL and Python.
Tables
violations(pin_id INTEGER, type VARCHAR, violation_date DATE)
Hints
- Create an index on (type, violation_date) to enable efficient range scans.
- In Python, pre-sort or group by policy type and use bisect_left/bisect_right on the date list to binary-search the date window.