Who Cleared the Cut-Off
A company visiting your campus has published the aptitude marks of everyone who wrote the test, along with the cut-off for the next round. The placement cell needs one number for its notice board: how many students are through.
A student clears the round if their mark is greater than or equal to the cut-off. Return how many students clear it.
Examples
Example 1
Input: marks = [72, 45, 60, 91, 59], cutoff = 60
Output: 3
The cut-off is 60. Checking each mark: 72 ✓, 45 ✗, 60 ✓ (equal counts as cleared), 91 ✓, 59 ✗. Three marks pass the test, so the answer is 3.
Example 2
Input: marks = [10, 20, 30], cutoff = 40
Output: 0
Example 3
Input: marks = [50, 50, 50, 50, 50], cutoff = 50
Output: 5
Constraints
marks has 1 to 10,000 entries, each between 0 and 100. cutoff is between 0 and 100.
Return the count of students whose mark is at least cutoff. If nobody clears it, return 0.
How to solve it
Hint
Count as you go: one counter, one condition, one pass.
Approach: Single pass · counting with a condition
- Start a counter at 0.
- For each mark, if it is greater than or equal to
cutoff, add 1 to the counter. - Return the counter.
Check with the example. With a cut-off of 60: 72 and 60 and 91 clear it; 45 and 59 do not. That is 3.
Complexity: O(n) time, O(1) space.
The reference solutions in all four languages are in the Solutions tab of the workspace below.
Item 2 of 90 · updated 2026-10-12