Ctrl K

The Fullest Bench

Easy
A teacher noted down who sat where in the schoolyard. Each entry of seating is a pair [student_id, bench_id]: student student_id sat on bench bench_id. The same entry may show up more than once; such a student still counts once for that bench. Return the largest number of different students on a single bench. If there are no entries, return 0.
Example 1
seating=[[4, 1], [7, 1], [4, 2], [9, 2], [12, 2]] → 3

Bench 1 holds students 4 and 7, bench 2 holds students 4, 9 and 12. The most is three.

Example 2
seating=[[5, 3], [5, 3], [5, 3]] → 1

These are three records of the same student on the same bench, so they count once.

Example 3
seating=[] → 0
Constraints
  • 0 ≤ len(seating) ≤ 100
  • 1 ≤ student_id ≤ 100
  • 1 ≤ bench_id ≤ 100
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsPair With a Target Sum EasyThe Candidate With Most Votes EasyDoes Any Value Repeat EasyRepeat Within Reach EasyThe Lost Ticket Easy
loading Python…
Input
seating=[[4, 1], [7, 1], [4, 2], [9, 2], [12, 2]]
Expected
3

Run checks the first 3 tests in your browser. Submit checks all 89 tests on the server, hidden ones included.