815. Maximum Students on a Single Bench

You are provided with a 2D integer array students representing seat occupancy logs, where each students[i] = [studentID, benchID] indicates that a specific student is seated on a specific bench.

Return the maximum number of unique students sitting on any single bench. If no students are present in the records, return 0.

Note: The logs may contain duplicate entries for the same student on the same bench, but each student must be counted only once per bench.

Example 1:

Input: students = [[5,10], [6,10], [5,10], [1,2], [2,2], [3,2]]

Output: 3

Explanation:

Bench 10 has two unique students: [5, 6]

Bench 2 has three unique students: [1, 2, 3]

The maximum number of unique students on a single bench is 3

Example 2:

Input: students = [[1,1], [2,1], [3,1], [10,5], [20,5]]

Output: 3

Explanation:

Bench 1 has three unique students: [1, 2, 3]

Bench 5 has two unique students: [10, 20]

The maximum number of unique students on a single bench is 3

Now Your Turn!

Pick the correct output for the given input

Input: students = [[7,7], [7,7], [7,7]]

(Give the output representing the maximum number of unique students on a single bench)

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 0 <= students.length <= 100
  • students[i] = [studentID, benchID]
  • 1 <= studentID <= 100
  • 1 <= benchID <= 100

Hints

Frequently Occurring Doubts

0
class Solution {
public:
int maxStudentsOnBench(vector<vector<int>>& students) {
}
};
Test Case

Input:

Students