-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
31 lines (28 loc) · 892 Bytes
/
Solution.java
File metadata and controls
31 lines (28 loc) · 892 Bytes
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
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Solution {
private static final Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
List<Integer> candles = new ArrayList<>();
int candlesCount = scan.nextInt();
for (int i = 0; i < candlesCount; i++) {
candles.add(scan.nextInt());
}
System.out.println(Result.birthdayCakeCandles(candles));
scan.close();
}
}
class Result {
public static int birthdayCakeCandles(List<Integer> candles) {
int max = candles.get(0);
int count = 0;
for (int i = 0; i < candles.size(); i++) {
if (candles.get(i) > max) {
max = candles.get(i);
count = 1;
} else if (candles.get(i) == max) count++;
}
return count;
}
}