Loading problem...
You are given a Seat table that stores the current student assigned to each seat index.
Columns:
Data guarantees:
Task: Create a reassignment ledger where every consecutive pair of seat ids is swapped:
If n is odd, the student at the last id keeps the same id.
Return the resulting table with exactly two columns:
Return rows ordered by id in ascending order.
Supported submission environments:
Seat:
| id | student |
|----|---------|
| 1 | Ada |
| 2 | Ben |
| 3 | Cara |
| 4 | Drew |
| 5 | Evan |[
{"id":1,"student":"Ben"},
{"id":2,"student":"Ada"},
{"id":3,"student":"Drew"},
{"id":4,"student":"Cara"},
{"id":5,"student":"Evan"}
]Pairs (1,2) and (3,4) are swapped. Because the row count is odd, id 5 remains unchanged.
Seat:
| id | student |
|----|---------|
| 1 | Nina |
| 2 | Omar |
| 3 | Pia |
| 4 | Quinn |[
{"id":1,"student":"Omar"},
{"id":2,"student":"Nina"},
{"id":3,"student":"Quinn"},
{"id":4,"student":"Pia"}
]The total row count is even, so every row is part of exactly one swapped pair.
Seat:
| id | student |
|----|---------|
| 1 | Alex |[
{"id":1,"student":"Alex"}
]A single row has no partner id to swap with, so output is unchanged.
Constraints