Skip to content

Practice Exchange Seats

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#626
LeetCode Problem

Exchange Seats

Problem Statement

Tables: Seat(id INT, student VARCHAR). Seat.id is unique and ranges consecutively from 1. Swap the students in seats 1 and 2, then 3 and 4, and so on. If the row count is odd, leave the final student in place. Return id and student ordered by id ascending.

Source: Exchange Seats on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
Seat table: +----+---------+ | id | student | +----+---------+ | 1  | Abbot   | | 2  | Doris   | | 3  | Emerson | | 4  | Green   | | 5  | Jeames  | +----+---------+
Output
+----+---------+ | id | student | +----+---------+ | 1  | Doris   | | 2  | Abbot   | | 3  | Green   | | 4  | Emerson | | 5  | Jeames  | +----+---------+

Related LeetCode Problems

Practice more problems similar to Exchange Seats.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.