The "Leetflex Banned Accounts interview question" is a SQL problem centered around security and concurrency. You are provided with a log of user logins and logouts, including the IP addresses used. A "banned" scenario occurs if a single account is accessed from two different IP addresses at the same time (i.e., the time intervals of the sessions overlap). Your goal is to identify all such user IDs. This "Leetflex Banned Accounts coding problem" is a practical application of interval overlapping logic in a database context.
This question is asked to test a candidate's ability to reason about temporal data and interval overlaps within a "Database interview pattern". It is highly relevant for roles involving system security, fraud detection, and account management. It checks if you can effectively use self-joins to compare different rows within the same table to find conflicting time windows.
The problem is solved using a self-join on the login history table. You join the table with itself on the user ID, with the additional condition that the IP addresses must be different. The core logic then checks for an overlap between two intervals [login1, logout1] and [login2, logout2]. Two intervals overlap if login1 <= logout2 AND login2 <= logout1.
Suppose User 10 has two login records:
start1 <= end2 AND start2 <= end1 formula.Interval overlap is a very common theme in both algorithmic and database questions. Memorize the standard overlap condition. Also, practice visualizing these intervals on a timeline to verify your logic quickly during an interview.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Active Businesses | Medium | Solve | |
| Active Users | Medium | Solve | |
| Activity Participants | Medium | Solve | |
| All People Report to the Given Manager | Medium | Solve | |
| All the Pairs With the Maximum Number of Common Followers | Medium | Solve |