2022-03-27 18:35:17 +08:00
{
"data" : {
"question" : {
"questionId" : "626" ,
"questionFrontendId" : "626" ,
"boundTopicId" : null ,
"title" : "Exchange Seats" ,
"titleSlug" : "exchange-seats" ,
2023-12-09 18:42:21 +08:00
"content" : "<p>Table: <code>Seat</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| id | int |\n| student | varchar |\n+-------------+---------+\nid is the primary key (unique value) column for this table.\nEach row of this table indicates the name and the ID of a student.\nid is a continuous increment.\n</pre>\n\n<p> </p>\n\n<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>\n\n<p>Return the result table ordered by <code>id</code> <strong>in ascending order</strong>.</p>\n\n<p>The result format is in the following example.</p>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nSeat table:\n+----+---------+\n| id | student |\n+----+---------+\n| 1 | Abbot |\n| 2 | Doris |\n| 3 | Emerson |\n| 4 | Green |\n| 5 | Jeames |\n+----+---------+\n<strong>Output:</strong> \n+----+---------+\n| id | student |\n+----+---------+\n| 1 | Doris |\n| 2 | Abbot |\n| 3 | Green |\n| 4 | Emerson |\n| 5 | Jeames |\n+----+---------+\n<strong>Explanation:</strong> \nNote that if the number of students is odd, there is no need to change the last one's seat.\n</pre>\n" ,
2022-03-27 18:35:17 +08:00
"translatedTitle" : null ,
"translatedContent" : null ,
"isPaidOnly" : false ,
"difficulty" : "Medium" ,
2023-12-09 19:57:46 +08:00
"likes" : 1264 ,
2023-12-09 18:42:21 +08:00
"dislikes" : 563 ,
2022-03-27 18:35:17 +08:00
"isLiked" : null ,
"similarQuestions" : "[]" ,
"exampleTestcases" : "{\"headers\": {\"Seat\": [\"id\",\"student\"]}, \"rows\": {\"Seat\": [[1,\"Abbot\"],[2,\"Doris\"],[3,\"Emerson\"],[4,\"Green\"],[5,\"Jeames\"]]}}" ,
"categoryTitle" : "Database" ,
"contributors" : [ ] ,
"topicTags" : [
{
"name" : "Database" ,
"slug" : "database" ,
"translatedName" : null ,
"__typename" : "TopicTagNode"
}
] ,
"companyTagStats" : null ,
"codeSnippets" : [
{
"lang" : "MySQL" ,
"langSlug" : "mysql" ,
"code" : "# Write your MySQL query statement below\n" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "MS SQL Server" ,
"langSlug" : "mssql" ,
"code" : "/* Write your T-SQL query statement below */\n" ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "Oracle" ,
"langSlug" : "oraclesql" ,
"code" : "/* Write your PL/SQL query statement below */\n" ,
"__typename" : "CodeSnippetNode"
2023-12-09 18:42:21 +08:00
} ,
{
"lang" : "Pandas" ,
"langSlug" : "pythondata" ,
"code" : "import pandas as pd\n\ndef exchange_seats(seat: pd.DataFrame) -> pd.DataFrame:\n " ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "PostgreSQL" ,
"langSlug" : "postgresql" ,
"code" : "-- Write your PostgreSQL query statement below\n" ,
"__typename" : "CodeSnippetNode"
2022-03-27 18:35:17 +08:00
}
] ,
2023-12-09 19:57:46 +08:00
"stats" : "{\"totalAccepted\": \"171K\", \"totalSubmission\": \"249.5K\", \"totalAcceptedRaw\": 170961, \"totalSubmissionRaw\": 249469, \"acRate\": \"68.5%\"}" ,
2022-03-27 18:35:17 +08:00
"hints" : [ ] ,
"solution" : {
"id" : "195" ,
2023-12-09 18:42:21 +08:00
"canSeeDetail" : false ,
"paidOnly" : true ,
2022-03-27 18:35:17 +08:00
"hasVideoSolution" : false ,
"paidOnlyVideo" : true ,
"__typename" : "ArticleNode"
} ,
"status" : null ,
"sampleTestCase" : "{\"headers\": {\"Seat\": [\"id\",\"student\"]}, \"rows\": {\"Seat\": [[1,\"Abbot\"],[2,\"Doris\"],[3,\"Emerson\"],[4,\"Green\"],[5,\"Jeames\"]]}}" ,
2023-12-09 18:42:21 +08:00
"metaData" : "{\"mysql\": [\"Create table If Not Exists Seat (id int, student varchar(255))\"], \"mssql\": [\"Create table Seat (id int, student varchar(255))\"], \"oraclesql\": [\"Create table Seat (id int, student varchar(255))\"], \"database\": true, \"name\": \"exchange_seats\", \"pythondata\": [\"Seat = pd.DataFrame([], columns=['id', 'student']).astype({'id':'Int64', 'student':'object'})\"], \"postgresql\": [\"\\nCreate table If Not Exists Seat (id int, student varchar(255))\"], \"database_schema\": {\"Seat\": {\"id\": \"INT\", \"student\": \"VARCHAR(255)\"}}}" ,
2022-03-27 18:35:17 +08:00
"judgerAvailable" : true ,
"judgeType" : "large" ,
"mysqlSchemas" : [
"Create table If Not Exists Seat (id int, student varchar(255))" ,
"Truncate table Seat" ,
"insert into Seat (id, student) values ('1', 'Abbot')" ,
"insert into Seat (id, student) values ('2', 'Doris')" ,
"insert into Seat (id, student) values ('3', 'Emerson')" ,
"insert into Seat (id, student) values ('4', 'Green')" ,
"insert into Seat (id, student) values ('5', 'Jeames')"
] ,
"enableRunCode" : true ,
"enableTestMode" : false ,
"enableDebugger" : false ,
2023-12-09 18:42:21 +08:00
"envInfo" : "{\"mysql\": [\"MySQL\", \"<p><code>MySQL 8.0</code>.</p>\"], \"mssql\": [\"MS SQL Server\", \"<p><code>mssql server 2019</code>.</p>\"], \"oraclesql\": [\"Oracle\", \"<p><code>Oracle Sql 11.2</code>.</p>\"], \"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"], \"postgresql\": [\"PostgreSQL\", \"<p>PostgreSQL 16</p>\"]}" ,
2022-03-27 18:35:17 +08:00
"libraryUrl" : null ,
"adminUrl" : null ,
"challengeQuestion" : null ,
"__typename" : "QuestionNode"
}
}
}