LeetCode solutions

2495. Number of Unique Subjects Taught by Each Teacher

My accepted SQL solution to LeetCode problem 2495, Number of Unique Subjects Taught by Each Teacher, running in 474ms.

  • Difficulty: Easy
  • SQL
  • Runtime 474ms
  • Memory 0.0B

Read the problem on LeetCode View on GitHub

SQL

Accepted on LeetCode — runtime 474ms, memory 0.0B, accepted 2026-01-01.

sql
SELECT teacher_id, COUNT(DISTINCT subject_id) AS cnt
FROM Teacher
GROUP BY teacher_id

Source