Trains the technique from
LeetCode 1431Kids With the Greatest Number of CandiesThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A collectors' club keeps a register of how many stamps each member owns, with stamps[i] the count held by member i. One bonus sheet carrying bonus further stamps is up for grabs.
Ask the same question of every member in turn: if this member alone were handed the whole bonus sheet, would their new count be at least as large as the count every other member holds today? Ties count as yes, and more than one member can answer yes.
Return a list answer of the same length as stamps, where answer[i] is true when member i answers yes and false when they do not. Every question is judged against the register as it stands, since the sheet is only ever handed out hypothetically.
Example 1
The largest holding on the register is 9. Member 0 would reach 8 and member 2 would reach 6, both short of 9. Members 1 and 3 would each reach 11.
Example 2
Either member would reach 8, which clears the other member's 7.
Example 3
Member 0 would reach exactly 20, which ties the largest holding and so counts as yes. Member 1 would reach 37 and member 2 would reach 22.
Example 4
The largest holding is 50. Member 1 would reach 29 and member 2 would reach 49, both short of it, while member 0 would reach 69.
Example 5
Member 1 would reach exactly 8, level with member 0's holding, and a tie answers yes.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def kids_with_candies(stamps: list[int], bonus: int) -> list[bool]:public List<Boolean> kidsWithCandies(int[] stamps, int bonus)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.