Kids With the Greatest Number of Candies

Big-O & the Python Toolkit, problem 2 of 7

Kids With the Greatest Number of Candies

Easy

LC #1431

arrayhidden cost

Not attempted yet

candies[i] is how many candies kid i has. You have extra_candies more to give away, all to one kid.

Return a list of booleans: True at position i if giving kid i all the extra candies would leave them with at least as many as every other kid.

Example 1

Input: candies = [2, 3, 5, 1, 3], extra_candies = 3
Output: [True, True, True, False, True]

The max is 5. Kid 3 reaches only 1 + 3 = 4.

Example 2

Input: candies = [4, 2, 1, 1, 2], extra_candies = 1
Output: [True, False, False, False, False]

Example 3

Input: candies = [10, 1, 10], extra_candies = 9
Output: [True, True, True]

Ties count as the greatest.

Constraints

  • 1 ≤ candies.length ≤ 10⁵
  • 0 ≤ candies[i], extra_candies ≤ 10⁹

Python

Loading draft…

Test results

8 tests available

No results yet

Run tests your code against the examples; Submit runs the hidden tests too.

3 examples, 5 hidden

Run examples, then submit all tests.