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
Files
leetcode-problemset/leetcode-cn/originData/find-students-who-improved.json
2025-02-02 13:55:38 +08:00

96 lines
12 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"data": {
"question": {
"questionId": "3767",
"questionFrontendId": "3421",
"categoryTitle": "Database",
"boundTopicId": 3046795,
"title": "Find Students Who Improved",
"titleSlug": "find-students-who-improved",
"content": "<p>Table: <code>Scores</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| student_id | int |\n| subject | varchar |\n| score | int |\n| exam_date | varchar |\n+-------------+---------+\n(student_id, subject, exam_date) is the primary key for this table.\nEach row contains information about a student&#39;s score in a specific subject on a particular exam date. score is between 0 and 100 (inclusive).\n</pre>\n\n<p>Write a solution to find the <strong>students who have shown improvement</strong>. A student is considered to have shown improvement if they meet <strong>both</strong> of these conditions:</p>\n\n<ul>\n\t<li>Have taken exams in the <strong>same subject</strong> on at least two different dates</li>\n\t<li>Their <strong>latest score</strong> in that subject is <strong>higher</strong> than their <strong>first score</strong></li>\n</ul>\n\n<p>Return <em>the result table</em>&nbsp;<em>ordered by</em> <code>student_id,</code> <code>subject</code> <em>in <strong>ascending</strong> order</em>.</p>\n\n<p>The result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example:</strong></p>\n\n<div class=\"example-block\">\n<p><strong>Input:</strong></p>\n\n<p>Scores table:</p>\n\n<pre class=\"example-io\">\n+------------+----------+-------+------------+\n| student_id | subject | score | exam_date |\n+------------+----------+-------+------------+\n| 101 | Math | 70 | 2023-01-15 |\n| 101 | Math | 85 | 2023-02-15 |\n| 101 | Physics | 65 | 2023-01-15 |\n| 101 | Physics | 60 | 2023-02-15 |\n| 102 | Math | 80 | 2023-01-15 |\n| 102 | Math | 85 | 2023-02-15 |\n| 103 | Math | 90 | 2023-01-15 |\n| 104 | Physics | 75 | 2023-01-15 |\n| 104 | Physics | 85 | 2023-02-15 |\n+------------+----------+-------+------------+\n</pre>\n\n<p><strong>Output:</strong></p>\n\n<pre class=\"example-io\">\n+------------+----------+-------------+--------------+\n| student_id | subject | first_score | latest_score |\n+------------+----------+-------------+--------------+\n| 101 | Math | 70 | 85 |\n| 102 | Math | 80 | 85 |\n| 104 | Physics | 75 | 85 |\n+------------+----------+-------------+--------------+\n</pre>\n\n<p><strong>Explanation:</strong></p>\n\n<ul>\n\t<li>Student 101 in Math: Improved from 70 to 85</li>\n\t<li>Student 101 in Physics: No improvement (dropped from 65 to 60)</li>\n\t<li>Student 102 in Math: Improved from 80 to 85</li>\n\t<li>Student 103 in Math: Only one exam, not eligible</li>\n\t<li>Student 104 in Physics: Improved from 75 to 85</li>\n</ul>\n\n<p>Result table is ordered by student_id, subject.</p>\n</div>\n",
"translatedTitle": "查找进步的学生",
"translatedContent": "<p>表:<code>Scores</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| student_id | int |\n| subject | varchar |\n| score | int |\n| exam_date | varchar |\n+-------------+---------+\n(student_id, subject, exam_date) 是这张表的主键。\n每一行包含有关学生在特定考试日期特定科目成绩的信息。分数范围从 0 到 100包括边界。\n</pre>\n\n<p>编写一个解决方案来查找 <strong>进步的学生</strong>。如果 <strong>同时</strong> 满足以下两个条件,则该学生被认为是进步的:</p>\n\n<ul>\n\t<li>在 <strong>同一科目</strong> 至少参加过两个不同日期的考试。</li>\n\t<li>他们在该学科<strong> 最近的分数 </strong>比他们 第一次该学科考试的分数更高。</li>\n</ul>\n\n<p>返回结果表以&nbsp;<code>student_id</code><code>subject</code> <strong>升序</strong>&nbsp;排序。</p>\n\n<p>结果格式如下所示。</p>\n\n<p>&nbsp;</p>\n\n<p><strong class=\"example\">示例:</strong></p>\n\n<div class=\"example-block\">\n<p><strong>输入:</strong></p>\n\n<p>Scores 表:</p>\n\n<pre>\n+------------+----------+-------+------------+\n| student_id | subject | score | exam_date |\n+------------+----------+-------+------------+\n| 101 | Math | 70 | 2023-01-15 |\n| 101 | Math | 85 | 2023-02-15 |\n| 101 | Physics | 65 | 2023-01-15 |\n| 101 | Physics | 60 | 2023-02-15 |\n| 102 | Math | 80 | 2023-01-15 |\n| 102 | Math | 85 | 2023-02-15 |\n| 103 | Math | 90 | 2023-01-15 |\n| 104 | Physics | 75 | 2023-01-15 |\n| 104 | Physics | 85 | 2023-02-15 |\n+------------+----------+-------+------------+</pre>\n\n<p><strong>出:</strong></p>\n\n<pre class=\"example-io\">\n+------------+----------+-------------+--------------+\n| student_id | subject | first_score | latest_score |\n+------------+----------+-------------+--------------+\n| 101 | Math | 70 | 85 |\n| 102 | Math | 80 | 85 |\n| 104 | Physics | 75 | 85 |\n+------------+----------+-------------+--------------+\n</pre>\n\n<p><strong>解释:</strong></p>\n\n<ul>\n\t<li>学生 101 的数学:从 70 分进步到 85 分。</li>\n\t<li>学生 101 的物理:没有进步(从 65 分退步到 60分</li>\n\t<li>学生 102 的数学:从 80 进步到 85 分。</li>\n\t<li>学生 103 的数学:只有一次考试,不符合资格。</li>\n\t<li>学生 104 的物理:从 75 分进步到 85 分。</li>\n</ul>\n\n<p>结果表以 student_idsubject 升序排序。</p>\n</div>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 0,
"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, \"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, \"cangjie\": false}",
"topicTags": [
{
"name": "Database",
"slug": "database",
"translatedName": "数据库",
"__typename": "TopicTagNode"
}
],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "MySQL",
"langSlug": "mysql",
"code": "# Write your MySQL query statement below",
"__typename": "CodeSnippetNode"
},
{
"lang": "MS SQL Server",
"langSlug": "mssql",
"code": "/* Write your T-SQL query statement below */",
"__typename": "CodeSnippetNode"
},
{
"lang": "Oracle",
"langSlug": "oraclesql",
"code": "/* Write your PL/SQL query statement below */",
"__typename": "CodeSnippetNode"
},
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef find_students_who_improved(scores: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
},
{
"lang": "PostgreSQL",
"langSlug": "postgresql",
"code": "-- Write your PostgreSQL query statement below",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"249\", \"totalSubmission\": \"404\", \"totalAcceptedRaw\": 249, \"totalSubmissionRaw\": 404, \"acRate\": \"61.6%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"Scores\":[\"student_id\",\"subject\",\"score\",\"exam_date\"]},\"rows\":{\"Scores\":[[101,\"Math\",70,\"2023-01-15\"],[101,\"Math\",85,\"2023-02-15\"],[101,\"Physics\",65,\"2023-01-15\"],[101,\"Physics\",60,\"2023-02-15\"],[102,\"Math\",80,\"2023-01-15\"],[102,\"Math\",85,\"2023-02-15\"],[103,\"Math\",90,\"2023-01-15\"],[104,\"Physics\",75,\"2023-01-15\"],[104,\"Physics\",85,\"2023-02-15\"]]}}",
"metaData": "{\"mysql\":[\"CREATE TABLE Scores (\\n student_id INT,\\n subject VARCHAR(50),\\n score INT,\\n exam_date VARCHAR(10)\\n)\"],\"mssql\":[\"CREATE TABLE Scores (\\n student_id INT,\\n subject VARCHAR(50),\\n score INT,\\n exam_date VARCHAR(10)\\n)\"],\"oraclesql\":[\"CREATE TABLE Scores (\\n student_id NUMBER,\\n subject VARCHAR2(50),\\n score NUMBER,\\n exam_date VARCHAR2(10)\\n)\"],\"database\":true,\"name\":\"find_students_who_improved\",\"postgresql\":[\"CREATE TABLE Scores (\\n student_id INT,\\n subject VARCHAR(50),\\n score INT,\\n exam_date VARCHAR(10)\\n);\\n\"],\"pythondata\":[\"Scores = pd.DataFrame({\\\"student_id\\\": pd.Series(dtype=\\\"int\\\"),\\n \\\"subject\\\": pd.Series(dtype=\\\"str\\\"),\\n \\\"score\\\": pd.Series(dtype=\\\"int\\\"),\\n \\\"exam_date\\\": pd.Series(dtype=\\\"str\\\")})\"],\"database_schema\":{\"Scores\":{\"student_id\":\"INT\",\"subject\":\"VARCHAR(50)\",\"score\":\"INT\",\"exam_date\":\"VARCHAR(10)\"}}}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"CREATE TABLE Scores (\n student_id INT,\n subject VARCHAR(50),\n score INT,\n exam_date VARCHAR(10)\n)",
"Truncate table Scores",
"insert into Scores (student_id, subject, score, exam_date) values ('101', 'Math', '70', '2023-01-15')",
"insert into Scores (student_id, subject, score, exam_date) values ('101', 'Math', '85', '2023-02-15')",
"insert into Scores (student_id, subject, score, exam_date) values ('101', 'Physics', '65', '2023-01-15')",
"insert into Scores (student_id, subject, score, exam_date) values ('101', 'Physics', '60', '2023-02-15')",
"insert into Scores (student_id, subject, score, exam_date) values ('102', 'Math', '80', '2023-01-15')",
"insert into Scores (student_id, subject, score, exam_date) values ('102', 'Math', '85', '2023-02-15')",
"insert into Scores (student_id, subject, score, exam_date) values ('103', 'Math', '90', '2023-01-15')",
"insert into Scores (student_id, subject, score, exam_date) values ('104', 'Physics', '75', '2023-01-15')",
"insert into Scores (student_id, subject, score, exam_date) values ('104', 'Physics', '85', '2023-02-15')"
],
"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>\"],\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.2.2 and NumPy 1.26.4<\\/p>\"],\"postgresql\":[\"PostgreSQL\",\"<p>PostgreSQL 16<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"Scores\":[\"student_id\",\"subject\",\"score\",\"exam_date\"]},\"rows\":{\"Scores\":[[101,\"Math\",70,\"2023-01-15\"],[101,\"Math\",85,\"2023-02-15\"],[101,\"Physics\",65,\"2023-01-15\"],[101,\"Physics\",60,\"2023-02-15\"],[102,\"Math\",80,\"2023-01-15\"],[102,\"Math\",85,\"2023-02-15\"],[103,\"Math\",90,\"2023-01-15\"],[104,\"Physics\",75,\"2023-01-15\"],[104,\"Physics\",85,\"2023-02-15\"]]}}",
"__typename": "QuestionNode"
}
}
}