Skip to content

Commit

Permalink
Create README - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
joseantoniochacon committed Jun 5, 2024
1 parent 1264622 commit c26c1e2
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions 2356-number-of-unique-subjects-taught-by-each-teacher/README.md
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>&nbsp;</p>

<p>Write a solution to calculate&nbsp;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&nbsp;result format is shown in the following example.</p>

<p>&nbsp;</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>

0 comments on commit c26c1e2

Please sign in to comment.