-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added README.md file for Exchange Seats
- Loading branch information
1 parent
b60f069
commit cc86fa8
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<h2><a href="https://leetcode.com/problems/exchange-seats">Exchange Seats</a></h2> <img src='https://img.shields.io/badge/Difficulty-Medium-orange' alt='Difficulty: Medium' /><hr><p>Table: <code>Seat</code></p> | ||
|
||
<pre> | ||
+-------------+---------+ | ||
| Column Name | Type | | ||
+-------------+---------+ | ||
| id | int | | ||
| student | varchar | | ||
+-------------+---------+ | ||
id is the primary key (unique value) column for this table. | ||
Each row of this table indicates the name and the ID of a student. | ||
The ID sequence always starts from 1 and increments continuously. | ||
</pre> | ||
|
||
<p> </p> | ||
|
||
<p>Write a solution to swap the seat id of every two consecutive students. If the number of students is odd, the id of the last student is not swapped.</p> | ||
|
||
<p>Return the result table ordered by <code>id</code> <strong>in ascending order</strong>.</p> | ||
|
||
<p>The result format is in the following example.</p> | ||
|
||
<p> </p> | ||
<p><strong class="example">Example 1:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> | ||
Seat table: | ||
+----+---------+ | ||
| id | student | | ||
+----+---------+ | ||
| 1 | Abbot | | ||
| 2 | Doris | | ||
| 3 | Emerson | | ||
| 4 | Green | | ||
| 5 | Jeames | | ||
+----+---------+ | ||
<strong>Output:</strong> | ||
+----+---------+ | ||
| id | student | | ||
+----+---------+ | ||
| 1 | Doris | | ||
| 2 | Abbot | | ||
| 3 | Green | | ||
| 4 | Emerson | | ||
| 5 | Jeames | | ||
+----+---------+ | ||
<strong>Explanation:</strong> | ||
Note that if the number of students is odd, there is no need to change the last one's seat. | ||
</pre> |