Suppress Repeat Push Notifications Inside a Cooldown Window

Last updated: November 29, 2026

Quick Overview

Given candidate Facebook push notifications as (user, timestamp, type), write Python that keeps a push only if the user has not received a kept push of the same type within the last hour, and caps each user at five kept pushes per day.

Meta
Data Manipulation (SQL/Python)
Software Engineer
Meta
November 29, 2026
Software Engineer
Technical Screen
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


Given candidate Facebook push notifications as (user, timestamp, type), write Python that keeps a push only if the user has not received a kept push of the same type within the last hour, and caps each user at five kept pushes per day.

Meta's notification ranking has guardrails against spamming users, and this screen question tests stateful dedupe in Python. The interviewer wants the rule measured from the last kept push (not the last candidate), ordering by time, and careful daily cap handling.

What the Interviewer Expects
  • Sorts candidates per user by time
  • Measures the cooldown from the last kept push, not the last candidate
  • Tracks state per (user, type) and per (user, day)
  • Applies the daily cap after the cooldown check
  • States O(n log n) time and O(users x types) memory
Key Topics to Cover
stateful deduplication
cooldown windows
greedy
hash maps
notifications
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would the result differ if cooldown were measured from the last candidate?
  • How would you prioritize which pushes to keep under the cap, rather than first come first served?
  • How would you implement this as a streaming operator?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

Input: list of (user_id, ts_seconds, notif_type) in arbitrary order. Rules: same type within 3600 seconds of the last kept push is suppressed; at most 5 kept pushes per user per UTC day across types...

Approach

Sort by user and time, then scan once. For each candidate, check the cooldown against last_kept[(user, type)]. If it passes, check the daily counter. If both pass, keep it and update state. Measurin...


Submit Your Answer
Markdown supported