Comments Left by Users the Post Author Had Already Blocked
Last updated: November 29, 2026
Quick Overview
Blocked users should not be able to comment on an Instagram author's posts. Using comments, posts, and a block history table with start and end times, find comments that were created while the commenter was blocked by the author.
Meta
November 29, 20260
0
0 solved
Blocked users should not be able to comment on an Instagram author's posts. Using comments, posts, and a block history table with start and end times, find comments that were created while the commenter was blocked by the author.
Integrity and privacy checks are a recurring theme in Meta data questions for engineers who own enforcement features. The interviewer is checking a three-way join with a time-range condition against a history table, and deduplication when block intervals overlap.
What the Interviewer Expects
- Joins comments to posts to get the author
- Joins block history on (blocker = author, blocked = commenter)
- Applies an interval condition with open-ended end times
- Uses EXISTS or DISTINCT so overlapping block rows do not duplicate comments
- Reports counts by day or client to help locate the bug
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you find which client versions produced the leaked comments?
- What if the block table only has the current state, not history?
- How would you make this check run continuously?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
comments(comment_id, post_id, commenter_id, created_at, client), posts(post_id, author_id), blocks(blocker_id, blocked_id, blocked_at, unblocked_at) where unblocked_at is NULL while still acti...
Approach
For each comment, find the author through posts, then check whether a block row covers the comment time. Using EXISTS keeps one output row per comment no matter how many block rows overlap. Treat a ...