← All problems

3. Kids With the Greatest Number of Candies

EasyArray / StringOriginal on LeetCode ↗

candies[i] is how many candies kid i has, and you also hold extraCandies spare candies.

For each kid, imagine giving them all of the spare candies. Would they then have at least as many candies as every other kid (ties count)? Return a list of booleans with the answer for each kid, in order.

Constraints

  • 2 <= len(candies) <= 100
  • 1 <= candies[i] <= 100
  • 1 <= extraCandies <= 50

Examples

Example 1
Input:  candies = [3,6,2,5,1], extraCandies = 2
Output: [false,true,false,true,false]
Example 2
Input:  candies = [7,1,1,1], extraCandies = 1
Output: [true,false,false,false]
Example 3
Input:  candies = [10,4,9], extraCandies = 3
Output: [true,false,true]

Hints

Hint 1

Find the current maximum once.

Hint 2

Kid i qualifies exactly when candies[i] + extraCandies >= that maximum.

Python 3

Run checks the examples · Submit checks every test. The first run downloads Python (about 10 MB) and takes a few seconds.