Skip to content

Commit 9d26c50

Browse files
authored
Create 1431-kids-with-the-greatest-number-of-candies.js
1 parent 7b9639b commit 9d26c50

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @param {number[]} candies
3+
* @param {number} extraCandies
4+
* @return {boolean[]}
5+
*/
6+
const kidsWithCandies = function(candies, extraCandies) {
7+
const res = []
8+
let max = 0
9+
for(let e of candies) max = Math.max(e, max)
10+
max -= extraCandies
11+
for(let i = 0, len = candies.length; i < len; i++) {
12+
res.push(candies[i] >= max)
13+
}
14+
return res
15+
};

0 commit comments

Comments
 (0)