Candy Leader Check
Imagine giving all the extra candies to each child one at a time and checking whether they would become a leader. Given a list candies, where each value is one child’s candy count, and a number extra_candies, return a list of booleans. For each child, return True if adding all extra candies would give them at least as many candies as any child has now.
Примеры
Ввод
[2, 3, 5, 1, 3], 3Вывод
[True, True, True, False, True]Ввод
[4, 2, 1, 1, 2], 1Вывод
[True, False, False, False, False]Ввод
[12, 1, 12], 10Вывод
[True, False, True]Нужно реализовать
def kids_with_candies(candies: list[int], extra_candies: int) -> list[bool]:
Теги
array
Inicia sesión para ver tu historial de envíos
Iniciar sesiónInicia sesión para usar el AI Mentor
Iniciar sesiónVisible tests
1
Input
[2,3,5,1,3], 3Expected
[true,true,true,false,true]2
Input
[4,2,1,1,2], 1Expected
[true,false,false,false,false]3
Input
[12,1,12], 10Expected
[true,false,true]4
Input
[5], 0Expected
[true]5
Input
[1,2,3], 100Expected
[true,true,true]6
Input
[4,2,1,1,2], -100Expected
[false,false,false,false,false]Focus radio
Paused · SomaFM · Fluid