From c26c1e21e31064421ccf77451639505f8ee83501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Antonio=20Chac=C3=B3n=20Guti=C3=A9rrez?= <138903866+joseantoniochacon@users.noreply.github.com> Date: Wed, 5 Jun 2024 15:08:15 -0600 Subject: [PATCH] Create README - LeetHub --- .../README.md | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 2356-number-of-unique-subjects-taught-by-each-teacher/README.md diff --git a/2356-number-of-unique-subjects-taught-by-each-teacher/README.md b/2356-number-of-unique-subjects-taught-by-each-teacher/README.md new file mode 100644 index 0000000..62d1fdc --- /dev/null +++ b/2356-number-of-unique-subjects-taught-by-each-teacher/README.md @@ -0,0 +1,55 @@ +
Table: Teacher
+-------------+------+ +| Column Name | Type | ++-------------+------+ +| teacher_id | int | +| subject_id | int | +| dept_id | int | ++-------------+------+ +(subject_id, dept_id) is the primary key (combinations of columns with unique values) of this table. +Each row in this table indicates that the teacher with teacher_id teaches the subject subject_id in the department dept_id. ++ +
+ +
Write a solution to calculate the number of unique subjects each teacher teaches in the university.
+ +Return the result table in any order.
+ +The result format is shown in the following example.
+ ++
Example 1:
+ +Input: +Teacher table: ++------------+------------+---------+ +| teacher_id | subject_id | dept_id | ++------------+------------+---------+ +| 1 | 2 | 3 | +| 1 | 2 | 4 | +| 1 | 3 | 3 | +| 2 | 1 | 1 | +| 2 | 2 | 1 | +| 2 | 3 | 1 | +| 2 | 4 | 1 | ++------------+------------+---------+ +Output: ++------------+-----+ +| teacher_id | cnt | ++------------+-----+ +| 1 | 2 | +| 2 | 4 | ++------------+-----+ +Explanation: +Teacher 1: + - They teach subject 2 in departments 3 and 4. + - They teach subject 3 in department 3. +Teacher 2: + - They teach subject 1 in department 1. + - They teach subject 2 in department 1. + - They teach subject 3 in department 1. + - They teach subject 4 in department 1. ++