1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-06 16:01:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

存量题库数据更新

This commit is contained in:
2023-12-09 18:42:21 +08:00
parent a788808cd7
commit c198538f10
10843 changed files with 288489 additions and 248355 deletions

View File

@@ -7,17 +7,17 @@
"boundTopicId": 1209,
"title": "Swap Salary",
"titleSlug": "swap-salary",
"content": "<p>Table: <code>Salary</code></p>\n\n<pre>\n+-------------+----------+\n| Column Name | Type |\n+-------------+----------+\n| id | int |\n| name | varchar |\n| sex | ENUM |\n| salary | int |\n+-------------+----------+\nid is the primary key for this table.\nThe sex column is ENUM value of type (&#39;m&#39;, &#39;f&#39;).\nThe table contains information about an employee.\n</pre>\n\n<p>&nbsp;</p>\n\n<p>Write an SQL query to swap all <code>&#39;f&#39;</code> and <code>&#39;m&#39;</code> values (i.e., change all <code>&#39;f&#39;</code> values to <code>&#39;m&#39;</code> and vice versa) with a <strong>single update statement</strong> and no intermediate temporary tables.</p>\n\n<p>Note that you must write a single update statement, <strong>do not</strong> write any select statement for this problem.</p>\n\n<p>The query result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong>Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nSalary table:\n+----+------+-----+--------+\n| id | name | sex | salary |\n+----+------+-----+--------+\n| 1 | A | m | 2500 |\n| 2 | B | f | 1500 |\n| 3 | C | m | 5500 |\n| 4 | D | f | 500 |\n+----+------+-----+--------+\n<strong>Output:</strong> \n+----+------+-----+--------+\n| id | name | sex | salary |\n+----+------+-----+--------+\n| 1 | A | f | 2500 |\n| 2 | B | m | 1500 |\n| 3 | C | f | 5500 |\n| 4 | D | m | 500 |\n+----+------+-----+--------+\n<strong>Explanation:</strong> \n(1, A) and (3, C) were changed from &#39;m&#39; to &#39;f&#39;.\n(2, B) and (4, D) were changed from &#39;f&#39; to &#39;m&#39;.\n</pre>\n",
"content": "<p>Table: <code>Salary</code></p>\n\n<pre>\n+-------------+----------+\n| Column Name | Type |\n+-------------+----------+\n| id | int |\n| name | varchar |\n| sex | ENUM |\n| salary | int |\n+-------------+----------+\nid is the primary key (column with unique values) for this table.\nThe sex column is ENUM (category) value of type (&#39;m&#39;, &#39;f&#39;).\nThe table contains information about an employee.\n</pre>\n\n<p>&nbsp;</p>\n\n<p>Write a solution to swap all <code>&#39;f&#39;</code> and <code>&#39;m&#39;</code> values (i.e., change all <code>&#39;f&#39;</code> values to <code>&#39;m&#39;</code> and vice versa) with a <strong>single update statement</strong> and no intermediate temporary tables.</p>\n\n<p>Note that you must write a single update statement, <strong>do not</strong> write any select statement for this problem.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nSalary table:\n+----+------+-----+--------+\n| id | name | sex | salary |\n+----+------+-----+--------+\n| 1 | A | m | 2500 |\n| 2 | B | f | 1500 |\n| 3 | C | m | 5500 |\n| 4 | D | f | 500 |\n+----+------+-----+--------+\n<strong>Output:</strong> \n+----+------+-----+--------+\n| id | name | sex | salary |\n+----+------+-----+--------+\n| 1 | A | f | 2500 |\n| 2 | B | m | 1500 |\n| 3 | C | f | 5500 |\n| 4 | D | m | 500 |\n+----+------+-----+--------+\n<strong>Explanation:</strong> \n(1, A) and (3, C) were changed from &#39;m&#39; to &#39;f&#39;.\n(2, B) and (4, D) were changed from &#39;f&#39; to &#39;m&#39;.\n</pre>\n",
"translatedTitle": "变更性别",
"translatedContent": "<div class=\"original__bRMd\">\n<div>\n<p><code>Salary</code> 表:</p>\n\n<pre>\n+-------------+----------+\n| Column Name | Type |\n+-------------+----------+\n| id | int |\n| name | varchar |\n| sex | ENUM |\n| salary | int |\n+-------------+----------+\nid 是这个表的主键。\nsex 这一列的值是 ENUM 类型,只能从 ('m', 'f') 中取。\n本表包含公司雇员的信息。\n</pre>\n\n<p>&nbsp;</p>\n\n<p>请你编写一个 SQL 查询来交换所有的 <code>'f'</code> 和 <code>'m'</code> (即,将所有 <code>'f'</code> 变为 <code>'m'</code> ,反之亦然),仅使用 <strong>单个 update 语句</strong> ,且不产生中间临时表。</p>\n\n<p>注意,你必须仅使用一条 update 语句,且 <strong>不能</strong> 使用 select 语句。</p>\n\n<p>查询结果如下例所示。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>\nSalary 表:\n+----+------+-----+--------+\n| id | name | sex | salary |\n+----+------+-----+--------+\n| 1 | A | m | 2500 |\n| 2 | B | f | 1500 |\n| 3 | C | m | 5500 |\n| 4 | D | f | 500 |\n+----+------+-----+--------+\n<strong>输出:</strong>\n+----+------+-----+--------+\n| id | name | sex | salary |\n+----+------+-----+--------+\n| 1 | A | f | 2500 |\n| 2 | B | m | 1500 |\n| 3 | C | f | 5500 |\n| 4 | D | m | 500 |\n+----+------+-----+--------+\n<strong>解释:</strong>\n(1, A) 和 (3, C) 从 'm' 变为 'f' 。\n(2, B) 和 (4, D) 从 'f' 变为 'm' 。</pre>\n</div>\n</div>\n",
"translatedContent": "<div class=\"original__bRMd\">\n<div>\n<p><code>Salary</code> 表:</p>\n\n<pre>\n+-------------+----------+\n| Column Name | Type |\n+-------------+----------+\n| id | int |\n| name | varchar |\n| sex | ENUM |\n| salary | int |\n+-------------+----------+\nid 是这个表的主键(具有唯一值的列)。\nsex 这一列的值是 ENUM 类型,只能从 ('m', 'f') 中取。\n本表包含公司雇员的信息。\n</pre>\n\n<p>&nbsp;</p>\n\n<p>请你编写一个解决方案来交换所有的 <code>'f'</code> 和 <code>'m'</code> (即,将所有 <code>'f'</code> 变为 <code>'m'</code> ,反之亦然),仅使用 <strong>单个 update 语句</strong> ,且不产生中间临时表。</p>\n\n<p>注意,你必须仅使用一条 update 语句,且 <strong>不能</strong> 使用 select 语句。</p>\n\n<p>结果如下例所示。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>\nSalary 表:\n+----+------+-----+--------+\n| id | name | sex | salary |\n+----+------+-----+--------+\n| 1 | A | m | 2500 |\n| 2 | B | f | 1500 |\n| 3 | C | m | 5500 |\n| 4 | D | f | 500 |\n+----+------+-----+--------+\n<strong>输出:</strong>\n+----+------+-----+--------+\n| id | name | sex | salary |\n+----+------+-----+--------+\n| 1 | A | f | 2500 |\n| 2 | B | m | 1500 |\n| 3 | C | f | 5500 |\n| 4 | D | m | 500 |\n+----+------+-----+--------+\n<strong>解释:</strong>\n(1, A) 和 (3, C) 从 'm' 变为 'f' 。\n(2, B) 和 (4, D) 从 'f' 变为 'm' 。</pre>\n</div>\n</div>\n",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 306,
"likes": 435,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}",
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
"topicTags": [
{
"name": "Database",
@@ -45,9 +45,21 @@
"langSlug": "oraclesql",
"code": "/* Write your PL/SQL query statement below */",
"__typename": "CodeSnippetNode"
},
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef swap_salary(salary: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
},
{
"lang": "PostgreSQL",
"langSlug": "postgresql",
"code": "-- Write your PostgreSQL query statement below",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"104.8K\", \"totalSubmission\": \"128.6K\", \"totalAcceptedRaw\": 104760, \"totalSubmissionRaw\": 128648, \"acRate\": \"81.4%\"}",
"stats": "{\"totalAccepted\": \"185.4K\", \"totalSubmission\": \"225.4K\", \"totalAcceptedRaw\": 185374, \"totalSubmissionRaw\": 225421, \"acRate\": \"82.2%\"}",
"hints": [],
"solution": {
"id": "93",
@@ -55,20 +67,20 @@
"__typename": "ArticleNode"
},
"status": null,
"sampleTestCase": "{\"headers\":{\"salary\":[\"id\",\"name\",\"sex\",\"salary\"]},\"rows\":{\"salary\":[[1,\"A\",\"m\",2500],[2,\"B\",\"f\",1500],[3,\"C\",\"m\",5500],[4,\"D\",\"f\",500]]}}",
"metaData": "{\n \"mysql\": [\n \"Create table If Not Exists Salary (id int, name varchar(100), sex char(1), salary int)\"\n ],\n \"mssql\": [\n \"Create table Salary (id int, name varchar(100), sex char(1), salary int)\"\n ],\n \"oraclesql\": [\n \"Create table Salary (id int, name varchar(100), sex char(1), salary int)\"\n ],\n \"database\": true,\n \"manual\": true\n}",
"sampleTestCase": "{\"headers\":{\"Salary\":[\"id\",\"name\",\"sex\",\"salary\"]},\"rows\":{\"Salary\":[[1,\"A\",\"m\",2500],[2,\"B\",\"f\",1500],[3,\"C\",\"m\",5500],[4,\"D\",\"f\",500]]}}",
"metaData": "{\"mysql\":[\"Create table If Not Exists Salary (id int, name varchar(100), sex char(1), salary int)\"],\"mssql\":[\"Create table Salary (id int, name varchar(100), sex char(1), salary int)\"],\"oraclesql\":[\"Create table Salary (id int, name varchar(100), sex char(1), salary int)\"],\"database\":true,\"manual\":true,\"name\":\"swap_salary\",\"pythondata\":[\"Salary = pd.DataFrame([], columns=['id', 'name', 'sex', 'salary']).astype({'id':'Int64', 'name':'object', 'sex':'object', 'salary':'Int64'})\\n\"],\"postgresql\":[\"Create table If Not Exists Salary (id int, name varchar, sex char, salary int)\\n\"],\"database_schema\":{\"Salary\":{\"id\":\"INT\",\"name\":\"VARCHAR(100)\",\"sex\":\"CHAR(1)\",\"salary\":\"INT\"}}}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"Create table If Not Exists Salary (id int, name varchar(100), sex char(1), salary int)",
"Truncate table salary",
"insert into salary (id, name, sex, salary) values ('1', 'A', 'm', '2500')",
"insert into salary (id, name, sex, salary) values ('2', 'B', 'f', '1500')",
"insert into salary (id, name, sex, salary) values ('3', 'C', 'm', '5500')",
"insert into salary (id, name, sex, salary) values ('4', 'D', 'f', '500')"
"Truncate table Salary",
"insert into Salary (id, name, sex, salary) values ('1', 'A', 'm', '2500')",
"insert into Salary (id, name, sex, salary) values ('2', 'B', 'f', '1500')",
"insert into Salary (id, name, sex, salary) values ('3', 'C', 'm', '5500')",
"insert into Salary (id, name, sex, salary) values ('4', 'D', 'f', '500')"
],
"enableRunCode": true,
"envInfo": "{\"mysql\":[\"MySQL\",\"<p>\\u7248\\u672c\\uff1a<code>MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"<p>mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\"<p>Oracle Sql 11.2.<\\/p>\"]}",
"envInfo": "{\"mysql\":[\"MySQL\",\"<p>\\u7248\\u672c\\uff1a<code>MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"<p>mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\"<p>Oracle Sql 11.2.<\\/p>\"],\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"],\"postgresql\":[\"PostgreSQL\",\"<p>PostgreSQL 16<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
@@ -76,7 +88,7 @@
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"salary\":[\"id\",\"name\",\"sex\",\"salary\"]},\"rows\":{\"salary\":[[1,\"A\",\"m\",2500],[2,\"B\",\"f\",1500],[3,\"C\",\"m\",5500],[4,\"D\",\"f\",500]]}}",
"exampleTestcases": "{\"headers\":{\"Salary\":[\"id\",\"name\",\"sex\",\"salary\"]},\"rows\":{\"Salary\":[[1,\"A\",\"m\",2500],[2,\"B\",\"f\",1500],[3,\"C\",\"m\",5500],[4,\"D\",\"f\",500]]}}",
"__typename": "QuestionNode"
}
}