51. Consecutive Status Runs (Gaps and Islands)
Difficulty: Hard · Topics: Window Functions, Aggregations
An advanced problem: unlock it to open the statement, sample data and editor. Graded on 3 test cases.
Learn the concepts
- Gaps and islands · 7 min read. Streaks, sessions and status runs: one window pattern behind many interview questions.
- row_number / rank · 4 min read. Number and rank rows inside a window, and how the three ranking functions treat ties.
- groupBy + agg · 4 min read. Aggregate rows per group: counts, sums, averages, and how count(*) differs from count(col).
PySpark functions you'll practise
- Row Number
- Window spec
- groupBy
- agg
- count
- min
- max
- withColumn
- orderBy
Related problems
- Three-Day Login Streak · Hard · Window Functions, Aggregations, Dates, Filtering & Selection
- Upsert: Merge New Records into a Table · Hard · Window Functions, Filtering & Selection
- Trailing 3 Calendar Days (Range Frame) · Hard · Window Functions, Dates, Filtering & Selection
- Forward-Fill Missing Readings · Hard · Window Functions
- Sessionize a Clickstream · Hard · Window Functions, Dates, Null Handling, Conditional Logic, Filtering & Selection
Browse
Topics: Window Functions · Joins · Aggregations · Pivot, Unpivot & Rollup · Arrays · Null Handling · Conditional Logic · Dates · Filtering & Selection · Strings · Data Lake · Lakehouse · Streaming · Data Prep for AI · Spark Performance
Difficulty: Easy · Medium · Hard · Learn · All problems · dbt practice