1280. Students and Examinations LeetCode Solution
In this guide, you will get 1280. Students and Examinations LeetCode Solution with the best time and space complexity. The solution to Students and Examinations problem is provided in various programming languages like C++, Java, and Python. This will be helpful for you if you are preparing for placements, hackathons, interviews, or practice purposes. The solutions provided here are very easy to follow and include detailed explanations.
Table of Contents
- Problem Statement
- Complexity Analysis
- Students and Examinations solution in C++
- Students and Examinations solution in Java
- Students and Examinations solution in Python
- Additional Resources

Problem Statement of Students and Examinations
Table: Students
+—————+———+
| Column Name | Type |
+—————+———+
| student_id | int |
| student_name | varchar |
+—————+———+
student_id is the primary key (column with unique values) for this table.
Each row of this table contains the ID and the name of one student in the school.
Table: Subjects
+————–+———+
| Column Name | Type |
+————–+———+
| subject_name | varchar |
+————–+———+
subject_name is the primary key (column with unique values) for this table.
Each row of this table contains the name of one subject in the school.
Table: Examinations
+————–+———+
| Column Name | Type |
+————–+———+
| student_id | int |
| subject_name | varchar |
+————–+———+
There is no primary key (column with unique values) for this table. It may contain duplicates.
Each student from the Students table takes every course from the Subjects table.
Each row of this table indicates that a student with ID student_id attended the exam of subject_name.
Write a solution to find the number of times each student attended each exam.
Return the result table ordered by student_id and subject_name.
The result format is in the following example.
Example not found
Constraints not found
Complexity Analysis
- Time Complexity: Google AdSense
- Space Complexity: Google Analytics
1280. Students and Examinations LeetCode Solution in C++
SELECT
Students.student_id,
Students.student_name,
Subjects.subject_name,
COUNT(Examinations.student_id) AS attended_exams
FROM Students
CROSS JOIN Subjects
LEFT JOIN Examinations
ON (
Students.student_id = Examinations.student_id
AND Subjects.subject_name = Examinations.subject_name)
GROUP BY 1, 2, 3
ORDER BY Students.student_id, Subjects.subject_name;
/* code provided by PROGIEZ */
1280. Students and Examinations LeetCode Solution in Java
N/A
// code provided by PROGIEZ
1280. Students and Examinations LeetCode Solution in Python
N/A
# code by PROGIEZ
Additional Resources
- Explore all LeetCode problem solutions at Progiez here
- Explore all problems on LeetCode website here
Happy Coding! Keep following PROGIEZ for more updates and solutions.