The Kids With the Greatest Number of Candies interview question is a simple comparison task. You are given an array candies and an integer extraCandies. For each kid, you need to determine if giving them all the extraCandies would make them have the greatest number of candies among all the kids.
Companies like Meta, Amazon, and Infosys use this as an introductory "Easy" question. It tests a candidate's ability to perform a Two-Pass Array scan and handle basic logic. It evaluations whether you can identify that you must find the current maximum before making individual comparisons.
This problem follows the Find Max and Compare pattern.
candies[i] + extraCandies >= maxCandies.candies = [2, 3, 5, 1, 3], extra = 3
[true, true, true, false, true].> instead of >=.Always look for the pre-requisite information. In many array problems, finding the global max, min, or sum is the necessary first step before individual elements can be evaluated. This is a basic Array interview pattern.