Skip to content

Commit dbf3e02

Browse files
committed
Added README.md file for Number of Unique Subjects Taught by Each Teacher
1 parent d29df56 commit dbf3e02

File tree

1 file changed

+56
-0
lines changed
  • 2495-number-of-unique-subjects-taught-by-each-teacher

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<h2><a href="https://leetcode.com/problems/number-of-unique-subjects-taught-by-each-teacher">Number of Unique Subjects Taught by Each Teacher</a></h2> <img src='https://img.shields.io/badge/Difficulty-Easy-brightgreen' alt='Difficulty: Easy' /><hr><p>Table: <code>Teacher</code></p>
2+
3+
<pre>
4+
+-------------+------+
5+
| Column Name | Type |
6+
+-------------+------+
7+
| teacher_id | int |
8+
| subject_id | int |
9+
| dept_id | int |
10+
+-------------+------+
11+
(subject_id, dept_id) is the primary key (combinations of columns with unique values) of this table.
12+
Each row in this table indicates that the teacher with teacher_id teaches the subject subject_id in the department dept_id.
13+
</pre>
14+
15+
<p>&nbsp;</p>
16+
17+
<p>Write a solution to calculate&nbsp;the number of unique subjects each teacher teaches in the university.</p>
18+
19+
<p>Return the result table in <strong>any order</strong>.</p>
20+
21+
<p>The&nbsp;result format is shown in the following example.</p>
22+
23+
<p>&nbsp;</p>
24+
<p><strong class="example">Example 1:</strong></p>
25+
26+
<pre>
27+
<strong>Input:</strong>
28+
Teacher table:
29+
+------------+------------+---------+
30+
| teacher_id | subject_id | dept_id |
31+
+------------+------------+---------+
32+
| 1 | 2 | 3 |
33+
| 1 | 2 | 4 |
34+
| 1 | 3 | 3 |
35+
| 2 | 1 | 1 |
36+
| 2 | 2 | 1 |
37+
| 2 | 3 | 1 |
38+
| 2 | 4 | 1 |
39+
+------------+------------+---------+
40+
<strong>Output:</strong>
41+
+------------+-----+
42+
| teacher_id | cnt |
43+
+------------+-----+
44+
| 1 | 2 |
45+
| 2 | 4 |
46+
+------------+-----+
47+
<strong>Explanation:</strong>
48+
Teacher 1:
49+
- They teach subject 2 in departments 3 and 4.
50+
- They teach subject 3 in department 3.
51+
Teacher 2:
52+
- They teach subject 1 in department 1.
53+
- They teach subject 2 in department 1.
54+
- They teach subject 3 in department 1.
55+
- They teach subject 4 in department 1.
56+
</pre>

0 commit comments

Comments
 (0)