Identify Session with Maximum Overlapping Sessions Count
Company: PayPal
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Onsite
Overview: This question evaluates temporal interval reasoning, set-based querying and aggregation skills, focusing on identifying and counting overlapping time intervals using SQL or equivalent Python data-manipulation tools.
Tables
sessions(session_id INTEGER, start_time TIMESTAMP, end_time TIMESTAMP)
Hints
- Self-join the table on interval overlap: a.start_time < b.end_time AND a.end_time > b.start_time.
- Aggregate by a.session_id to count overlaps; include zero-overlap sessions, then order by overlap count DESC and session_id ASC for tie-breaking, and limit to 1.