Explain the gaps and islands pattern: finding consecutive runs and breaks with SQL window functions
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Other
Overview: Asks how to group consecutive rows of a SQL table into runs (islands) and find the breaks between them (gaps), and which window functions do the work. Tests partitioning and ordering logic, building a group key, and edge cases such as duplicate rows and timestamps.