Drop Moderation Bans Fully Contained in a Longer Ban
Last updated: November 29, 2026
Quick Overview
A user's moderation history is a list of ban windows [start, end]. Remove every ban fully covered by another ban (c <= a and b <= d) and return how many bans remain.
Meta
November 29, 20260
0
0 solved
A user's moderation history is a list of ban windows [start, end]. Remove every ban fully covered by another ban (c <= a and b <= d) and return how many bans remain.
A light interval problem in the style of Meta's phone screens, set in integrity tooling that cleans redundant enforcement records before showing a reviewer the history. The interviewer checks the sort order trick that makes a single pass correct, especially for bans that share a start.
What the Interviewer Expects
- Sorts by start ascending and end descending
- Explains why the tie-break matters for equal starts
- Tracks the max end seen so far
- Counts a ban as remaining only if it extends past that max
- Clarifies how identical bans are treated
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you return the remaining bans themselves?
- What if partial overlaps should also be merged?
- How would you handle this for millions of users in a batch job?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: list of inclusive [start, end] bans. Output: number of bans not covered by any other ban. Identical bans cover each other, so only one copy should remain; confirm that with the interviewer....
High-Level Design
Sort by start ascending and, on ties, end descending. Now any ban that could cover the current one appears earlier. Keep max_end over all bans seen. The current ban is covered exactly when its end i...