Skip to content
Decoder

Kids With the Greatest Number of Candies

Easy

Problem

Kid i has candies[i] candies, and you have extra_candies to hand out. For each kid, imagine giving all of the extra candies to that one kid. Would they then have the greatest number of candies (ties count)? Return a list of booleans, one per kid.

Example 1

Input
candies = [2, 3, 5, 1, 3], extra_candies = 3
Output
[true, true, true, false, true]

Example 2

Input
candies = [4, 2, 1, 1, 2], extra_candies = 1
Output
[true, false, false, false, false]

Constraints

  • 2 <= candies.length <= 100
  • 1 <= candies[i] <= 100
  • 1 <= extra_candies <= 50

Read it once before you touch anything

Want some pressure? Start the timer. In an interview you get about two minutes to understand the problem.

  1. 1Read the goalWhat goes in, what comes out
  2. 2Scan the examplesCheck one by hand
  3. 3Note the constraintsThey set your Big O
Say what it asks in one sentence
Say it out loud first, then compare with ours.