Skip to content

Commit 1f857c1

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

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
impl Solution {
2+
pub fn kids_with_candies(candies: Vec<i32>, extra_candies: i32) -> Vec<bool> {
3+
let mut max = 0;
4+
5+
for i in 0..candies.len() {
6+
if candies[i] > max {
7+
max = candies[i];
8+
}
9+
}
10+
11+
let mut result = Vec::new();
12+
13+
for i in 0..candies.len() {
14+
if candies[i] + extra_candies >= max {
15+
result.push(true);
16+
} else {
17+
result.push(false);
18+
}
19+
}
20+
21+
result
22+
}
23+
}

0 commit comments

Comments
 (0)