-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1264622
commit c26c1e2
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
2356-number-of-unique-subjects-taught-by-each-teacher/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<h2><a href="https://leetcode.com/problems/number-of-unique-subjects-taught-by-each-teacher/">2356. Number of Unique Subjects Taught by Each Teacher</a></h2><h3>Easy</h3><hr><div class="sql-schema-wrapper__3VBi"><a class="sql-schema-link__3cEg">SQL Schema<svg viewBox="0 0 24 24" width="1em" height="1em" class="icon__1Md2"><path fill-rule="evenodd" d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"></path></svg></a></div><div><p>Table: <code>Teacher</code></p> | ||
|
||
<pre>+-------------+------+ | ||
| 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. | ||
</pre> | ||
|
||
<p> </p> | ||
|
||
<p>Write a solution to calculate the number of unique subjects each teacher teaches in the university.</p> | ||
|
||
<p>Return the result table in <strong>any order</strong>.</p> | ||
|
||
<p>The result format is shown in the following example.</p> | ||
|
||
<p> </p> | ||
<p><strong class="example">Example 1:</strong></p> | ||
|
||
<pre><strong>Input:</strong> | ||
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 | | ||
+------------+------------+---------+ | ||
<strong>Output:</strong> | ||
+------------+-----+ | ||
| teacher_id | cnt | | ||
+------------+-----+ | ||
| 1 | 2 | | ||
| 2 | 4 | | ||
+------------+-----+ | ||
<strong>Explanation:</strong> | ||
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. | ||
</pre> | ||
</div> |