Question bank › Greedy
Dsa Greedy Easy

Classroom Seating Arrangement

In a classroom of students, each student needs a specific number of seats. Your goal is to determine the maximum number of students that can be accommodated given a number of available seats. Each student will occupy the exact seats they require. Write a program that reads the number of available seats and a list of seat requirements, and outputs the maximum number of students that can be seated. Input format: - The first line contains an integer S (total available seats). - The second line contains an integer M (number of students). - The third line contains M space-separated integers (each student’s seat requirement). Output format: - A single integer, the maximum number of students that can be seated. Example: Input: 15 4 3 1 5 2 Output: 3

Key concepts

greedysortingarrays

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.