mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
98 lines
7.1 KiB
JSON
98 lines
7.1 KiB
JSON
{
|
|
"data": {
|
|
"question": {
|
|
"questionId": "2495",
|
|
"questionFrontendId": "2356",
|
|
"boundTopicId": null,
|
|
"title": "Number of Unique Subjects Taught by Each Teacher",
|
|
"titleSlug": "number-of-unique-subjects-taught-by-each-teacher",
|
|
"content": "<p>Table: <code>Teacher</code></p>\n\n<pre>\n+-------------+------+\n| Column Name | Type |\n+-------------+------+\n| teacher_id | int |\n| subject_id | int |\n| dept_id | int |\n+-------------+------+\n(subject_id, dept_id) is the primary key (combinations of columns with unique values) of this table.\nEach row in this table indicates that the teacher with teacher_id teaches the subject subject_id in the department dept_id.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to calculate the number of unique subjects each teacher teaches in the university.</p>\n\n<p>Return the result table in <strong>any order</strong>.</p>\n\n<p>The result format is shown 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> \nTeacher table:\n+------------+------------+---------+\n| teacher_id | subject_id | dept_id |\n+------------+------------+---------+\n| 1 | 2 | 3 |\n| 1 | 2 | 4 |\n| 1 | 3 | 3 |\n| 2 | 1 | 1 |\n| 2 | 2 | 1 |\n| 2 | 3 | 1 |\n| 2 | 4 | 1 |\n+------------+------------+---------+\n<strong>Output:</strong> \n+------------+-----+\n| teacher_id | cnt |\n+------------+-----+\n| 1 | 2 |\n| 2 | 4 |\n+------------+-----+\n<strong>Explanation:</strong> \nTeacher 1:\n - They teach subject 2 in departments 3 and 4.\n - They teach subject 3 in department 3.\nTeacher 2:\n - They teach subject 1 in department 1.\n - They teach subject 2 in department 1.\n - They teach subject 3 in department 1.\n - They teach subject 4 in department 1.\n</pre>\n",
|
|
"translatedTitle": null,
|
|
"translatedContent": null,
|
|
"isPaidOnly": false,
|
|
"difficulty": "Easy",
|
|
"likes": 323,
|
|
"dislikes": 19,
|
|
"isLiked": null,
|
|
"similarQuestions": "[]",
|
|
"exampleTestcases": "{\"headers\":{\"Teacher\":[\"teacher_id\",\"subject_id\",\"dept_id\"]},\"rows\":{\"Teacher\":[[1,2,3],[1,2,4],[1,3,3],[2,1,1],[2,2,1],[2,3,1],[2,4,1]]}}",
|
|
"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"
|
|
},
|
|
{
|
|
"lang": "Pandas",
|
|
"langSlug": "pythondata",
|
|
"code": "import pandas as pd\n\ndef count_unique_subjects(teacher: pd.DataFrame) -> pd.DataFrame:\n ",
|
|
"__typename": "CodeSnippetNode"
|
|
},
|
|
{
|
|
"lang": "PostgreSQL",
|
|
"langSlug": "postgresql",
|
|
"code": "-- Write your PostgreSQL query statement below\n",
|
|
"__typename": "CodeSnippetNode"
|
|
}
|
|
],
|
|
"stats": "{\"totalAccepted\": \"79.2K\", \"totalSubmission\": \"91.6K\", \"totalAcceptedRaw\": 79225, \"totalSubmissionRaw\": 91592, \"acRate\": \"86.5%\"}",
|
|
"hints": [],
|
|
"solution": {
|
|
"id": "2014",
|
|
"canSeeDetail": false,
|
|
"paidOnly": true,
|
|
"hasVideoSolution": false,
|
|
"paidOnlyVideo": true,
|
|
"__typename": "ArticleNode"
|
|
},
|
|
"status": null,
|
|
"sampleTestCase": "{\"headers\":{\"Teacher\":[\"teacher_id\",\"subject_id\",\"dept_id\"]},\"rows\":{\"Teacher\":[[1,2,3],[1,2,4],[1,3,3],[2,1,1],[2,2,1],[2,3,1],[2,4,1]]}}",
|
|
"metaData": "{\"mysql\": [\"Create table If Not Exists Teacher (teacher_id int, subject_id int, dept_id int)\"], \"mssql\": [\"Create table Teacher (teacher_id int, subject_id int, dept_id int)\"], \"oraclesql\": [\"Create table Teacher (teacher_id int, subject_id int, dept_id int)\"], \"database\": true, \"name\": \"count_unique_subjects\", \"pythondata\": [\"Teacher = pd.DataFrame([], columns=['teacher_id', 'subject_id', 'dept_id']).astype({'teacher_id':'Int64', 'subject_id':'Int64', 'dept_id':'Int64'})\"], \"postgresql\": [\"Create table If Not Exists Teacher (teacher_id int, subject_id int, dept_id int)\"], \"database_schema\": {\"Teacher\": {\"teacher_id\": \"INT\", \"subject_id\": \"INT\", \"dept_id\": \"INT\"}}}",
|
|
"judgerAvailable": true,
|
|
"judgeType": "large",
|
|
"mysqlSchemas": [
|
|
"Create table If Not Exists Teacher (teacher_id int, subject_id int, dept_id int)",
|
|
"Truncate table Teacher",
|
|
"insert into Teacher (teacher_id, subject_id, dept_id) values ('1', '2', '3')",
|
|
"insert into Teacher (teacher_id, subject_id, dept_id) values ('1', '2', '4')",
|
|
"insert into Teacher (teacher_id, subject_id, dept_id) values ('1', '3', '3')",
|
|
"insert into Teacher (teacher_id, subject_id, dept_id) values ('2', '1', '1')",
|
|
"insert into Teacher (teacher_id, subject_id, dept_id) values ('2', '2', '1')",
|
|
"insert into Teacher (teacher_id, subject_id, dept_id) values ('2', '3', '1')",
|
|
"insert into Teacher (teacher_id, subject_id, dept_id) values ('2', '4', '1')"
|
|
],
|
|
"enableRunCode": true,
|
|
"enableTestMode": false,
|
|
"enableDebugger": false,
|
|
"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>\"]}",
|
|
"libraryUrl": null,
|
|
"adminUrl": null,
|
|
"challengeQuestion": null,
|
|
"__typename": "QuestionNode"
|
|
}
|
|
}
|
|
} |