We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
给你一个数组 candies 和一个整数 extraCandies ,其中 candies[i] 代表第 i 个孩子拥有的糖果数目。
candies
extraCandies
candies[i]
i
对每一个孩子,检查是否存在一种方案,将额外的 extraCandies 个糖果分配给孩子们之后,此孩子有 最多 的糖果。注意,允许有多个孩子同时拥有 最多 的糖果数目。
Input: candies = [2,3,5,1,3], extraCandies = 3 Output: [true,true,true,false,true] Explanation: 孩子 1 有 2 个糖果,如果他得到所有额外的糖果(3个),那么他总共有 5 个糖果,他将成为拥有最多糖果的孩子。 孩子 2 有 3 个糖果,如果他得到至少 2 个额外糖果,那么他将成为拥有最多糖果的孩子。 孩子 3 有 5 个糖果,他已经是拥有最多糖果的孩子。 孩子 4 有 1 个糖果,即使他得到所有额外的糖果,他也只有 4 个糖果,无法成为拥有糖果最多的孩子。 孩子 5 有 3 个糖果,如果他得到至少 2 个额外糖果,那么他将成为拥有最多糖果的孩子。
Input: candies = [4,2,1,1,2], extraCandies = 1 Output: [true,false,false,false,false] Explanation: 只有 1 个额外糖果,所以不管额外糖果给谁,只有孩子 1 可以成为拥有糖果最多的孩子。
Input: candies = [12,1,12], extraCandies = 10 Output: [true,false,true]
2 <= candies.length <= 100
1 <= candies[i] <= 100
1 <= extraCandies <= 50
The text was updated successfully, but these errors were encountered:
/** * @param {number[]} candies * @param {number} extraCandies * @return {boolean[]} */ var kidsWithCandies = function(candies, extraCandies) { const currentMaxcandy = Math.max(...candies); return candies.map((candy) => candy + extraCandies >= currentMaxcandy); };
var kidsWithCandies = function(candies: number[], extraCandies: number): boolean[] { const currentMaxcandy = Math.max(...candies); return candies.map((candy) => candy + extraCandies >= currentMaxcandy); };
Sorry, something went wrong.
No branches or pull requests
1431. Kids With the Greatest Number of Candies
给你一个数组
candies
和一个整数extraCandies
,其中candies[i]
代表第i
个孩子拥有的糖果数目。对每一个孩子,检查是否存在一种方案,将额外的
extraCandies
个糖果分配给孩子们之后,此孩子有 最多 的糖果。注意,允许有多个孩子同时拥有 最多 的糖果数目。Example 1
Example 2
Example 3
Note
2 <= candies.length <= 100
1 <= candies[i] <= 100
1 <= extraCandies <= 50
The text was updated successfully, but these errors were encountered: