EASYasked at 1 company

Number of Unique Subjects Taught by Each Teacher

A easy-tier problem at 89% community acceptance, tagged with Database. Reported in interviews at Capgemini and 0 others.

Founder's read

You're staring at a SQL problem about teachers and subjects, and it looks simple until you realize you need to handle the GROUP BY logic correctly. This one's asked at Capgemini and sits at the easier end of the difficulty spectrum, but the acceptance rate of 89% masks a common mistake: forgetting to count distinct subjects per teacher or grouping incorrectly. It's a database fundamentals check. If this hits your live assessment and you blank on the exact syntax or second-guess your GROUP BY, StealthCoder surfaces a working solution in seconds, invisible to the proctor.

Companies asking
1
Difficulty
EASY
Acceptance
89%

Companies that ask "Number of Unique Subjects Taught by Each Teacher"

If this hits your live OA

Number of Unique Subjects Taught by Each Teacher is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.

Get StealthCoder
What this means

The core task is straightforward: query a teacher and subject relationship table, count the unique subjects each teacher handles, and return the teacher ID with a subject count column. The trick isn't algorithmic complexity; it's SQL precision. Most candidates either forget to use COUNT(DISTINCT subject_id) instead of COUNT(*), or they structure their SELECT clause to include columns not in the GROUP BY without aggregation, which fails in strict SQL modes. The pitfall is overcomplicating it or misunderstanding what 'unique' means in context. StealthCoder is the hedge when you're unsure whether DISTINCT goes inside the COUNT, outside it, or if you need a subquery at all.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Number of Unique Subjects Taught by Each Teacher recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Number of Unique Subjects Taught by Each Teacher interview FAQ

Is this problem really just a GROUP BY with COUNT?+

Yes. It tests whether you know to use COUNT(DISTINCT subject_id) grouped by teacher_id. No subqueries needed. The 89% acceptance rate reflects how straightforward the logic is; the 11% failure comes from syntax errors or wrong aggregate function choices.

Will Capgemini ask database questions at every interview stage?+

Unknown from the data. This problem appears in their reported questions, but we don't know interview structure or when it's asked. Treat it as a realistic scenario: one OA question, one chance to get it right. That's where StealthCoder matters.

Do I need to use DISTINCT or a subquery to avoid double-counting?+

Use COUNT(DISTINCT subject_id) in a single query. No subquery required. If you write a subquery, you're overcomplicating it and introducing failure points. The DISTINCT keyword inside COUNT handles the uniqueness.

What if a teacher has no subjects assigned?+

Depends on your table schema and whether you're using INNER or OUTER joins. The problem doesn't specify, so check the schema. If teachers can exist without subjects, you might need a LEFT JOIN and handle NULL counts.

Is this problem actually asked at the start of an OA or mid-loop?+

Unknown. It's confirmed in Capgemini reports, but interview placement isn't in the data. Treat it as a warm-up or validation question: easy difficulty, high acceptance rate, low stakes relative to harder problems.

Want the actual problem statement? View "Number of Unique Subjects Taught by Each Teacher" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.