SQL: Exchange Seats
Medium
SQL — Advanced
SQL
CASE WHEN
MOD
Swap consecutive seat IDs.
Constraints
Write standard SQL (MySQL 8.0 compatible).
Examples
Example 1:
Input: 1 Ahmed
2 Sara
3 Omar
Output:
Example 2:
Input: 1 Ahmed
2 Sara
3 Omar
Output:
Hints
CASE WHEN with MOD.
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console