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.
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.