-
Notifications
You must be signed in to change notification settings - Fork 0
/
Candies.java
34 lines (30 loc) · 949 Bytes
/
Candies.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class Candies {
public static List<Boolean> kidsWithCandies(int[] candies, int extraCandies) {
int max = maxCandies(candies);
List<Boolean> list = new ArrayList<>();
for (int index = 0; index < candies.length; index++) {
int aux = candies[index];
int sum = aux+extraCandies;
if(sum>=max) list.add(true);
else list.add(false);
}
return list;
}
public static int maxCandies(int[] kids){
int max = 0;
for(int i = 0;i<kids.length;i++){
int aux = kids[i];
if(aux>max) max=aux;
}
return max;
}
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int[] list = {1,4,5};
System.out.print(kidsWithCandies(list,3));
}
}