Dsa
Greedy
Hard
Maximum Rides on a Ferris Wheel
You are managing a Ferris wheel at an amusement park, which has a limited number of seats and can only operate for a specific time. Given the heights of customers and the height limit of the Ferris wheel, you want to determine how many customers can enjoy a ride given that the wheel can operate only for a limited number of time slots.
Input Format:
- The first line contains two integers N (1 <= N <= 1000) and T (1 <= T <= 1000), the number of customers and the time slots available.
- The next line contains N integers, representing the heights of the customers (1 <= height <= 300). Each customer enters the Ferris wheel if they fall within the height limit, which is 200 cm.
Output Format:
- Print a single integer indicating the number of customers that can be seated during the time slots.
Example:
Input:
5 3
150 180 190 200 210
Output:
3
In this case, three out of five customers can enjoy the Ferris wheel as only those with heights 150, 180, and 190 are below the height limit.
Key concepts
greedysortingbinary search
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