PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches

Quick 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.

  • Medium
  • Pinterest
  • Data Manipulation (SQL/Python)
  • Data Scientist

Implement Binary Search for Policy Violation Logs

Company: Pinterest

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Onsite

violations +--------+---------+---------------+ | pin_id | type | violation_date| +--------+---------+---------------+ | 0 | spam | 2022-01-03 | | 1 | spam | 2022-01-03 | | 0 | privacy | 2022-01-03 | | 2 | child | 2022-02-06 | | 3 | spam | 2022-02-10 | +--------+---------+---------------+ ##### Scenario Pinterest wants to query pins that violated specific policies quickly from daily logs. ##### Question Write SQL/Python to return all pin_ids that violated a given policy type. Logs are date-sorted; add a function that, for a (policy, start_date, end_date), returns the matching pins using binary search rather than full scan. ##### Hints Create index on (type, violation_date); in Python, bisect left/right on pre-sorted list of dates.

Quick Answer: 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.

Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Write Queries for Pinterest Engagement Tasks - Pinterest (medium)
  • Write SQL for top categories and highly active users - Pinterest (easy)
  • Compute percent of first-cancelled users who never rebook - Pinterest (medium)
  • Compute percent of first-cancel users who never return - Pinterest (easy)
  • Find top category by video time spent - Pinterest (Medium)