Skip to content

Commit 1ea07e4

Browse files
committed
added solution in golang: 1431. Kids With the Greatest Number of Candies
Signed-off-by: rajput-hemant <rajput.hemant2001@gmail.com>
1 parent 1f857c1 commit 1ea07e4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package main
2+
3+
func kidsWithCandies(candies []int, extraCandies int) []bool {
4+
max := 0
5+
6+
for _, candy := range candies {
7+
if candy > max {
8+
max = candy
9+
}
10+
}
11+
12+
result := make([]bool, len(candies))
13+
14+
for i, candy := range candies {
15+
if candy+extraCandies >= max {
16+
result[i] = true
17+
}
18+
}
19+
20+
return result
21+
}

0 commit comments

Comments
 (0)