Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1ea07e4

Browse files
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
Lines changed: 21 additions & 0 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /