SQL: Gap Analysis
Medium
SQL — Advanced
SQL
LAG
Gap
Find gaps in sequential IDs.
Constraints
Write standard SQL (MySQL 8.0 compatible).
Examples
Example 1:
Input: id: 1,2,4,7
Output:
Example 2:
Input: id: 1,2,4,7
Output:
Hints
Self-join or window functions.
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console