Ctrl K

Weed Out the Low Scores

Easy
You are given an array of results scores and a passing mark bar. One move deletes a single occurrence of the smallest value in the array. How many moves does it take until every remaining result is at least bar?
Example 1
scores=[40, 75, 12, 90, 60], bar=60 → 2

Remove 12, then 40; what is left is 75, 90 and 60, all at least 60. Two moves.

Example 2
scores=[8, 8, 9], bar=8 → 0

Every value is already at least 8, so nothing has to go.

Example 3
scores=[3, 1, 4, 1, 5], bar=5 → 4
Constraints
  • 1 ≤ len(scores) ≤ 50
  • 1 ≤ scores[i] ≤ 10⁹
  • 1 ≤ bar ≤ 10⁹
  • At least one result is at least bar
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsPair With a Target Sum EasySqueeze Repeats Out of a Sorted Array EasyDrop the Unwanted Value EasySlot on a Sorted Shelf EasyAdd One to a Digit Array Easy
loading Python…
Input
scores=[40, 75, 12, 90, 60], bar=60
Expected
2

Run checks the first 3 tests in your browser. Submit checks all 101 tests on the server, hidden ones included.