Apply a Daily Per-User Cap to Group Post Notifications

Last updated: November 29, 2026

Quick Overview

Group posts generate candidate notifications (user_id, notif_id, created_at, priority). Enforce a cap of 3 notifications per user per local day, keeping the highest priority ones (earliest first on ties), and report how many were suppressed per user.

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

0

0

0 solved


Group posts generate candidate notifications (user_id, notif_id, created_at, priority). Enforce a cap of 3 notifications per user per local day, keeping the highest priority ones (earliest first on ties), and report how many were suppressed per user.

Facebook limits notification volume to avoid fatigue, and a backtest of a new cap is often prototyped in pandas. The question checks ranking within a group with multiple sort keys, cumcount-based filtering, and producing both the kept set and a suppression report.

What the Interviewer Expects
  • Group by user and day, not just user
  • Sort by priority descending then created_at ascending for deterministic ranking
  • Use cumcount to rank within the group and filter rank < cap
  • Report suppressed counts including users with zero suppression
  • Keep the kept notifications in chronological order for delivery
Key Topics to Cover
cumcount
multi-key sort
groupby
rate limiting
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 a rolling 24-hour cap differ from a calendar-day cap in implementation?
  • How would you evaluate the cap's impact on engagement before launching?
  • What if high-priority notifications (like security alerts) must bypass the cap?
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

cands(user_id, notif_id, created_at, priority) with higher priority meaning more important. Day is the calendar date of created_at (already local). Cap is 3 per user per day. Output: kept (rows ...

Approach

Add a day column. Sort by user, day, priority descending, created_at ascending, notif_id ascending. groupby([user, day]).cumcount() then ranks within each user-day; keep rows with rank < cap. Mark...


Submit Your Answer
Markdown supported