"Birthday Cake Candles" is the name of this problem in HackerRank This is the working code and if I replace "int" with "Integer" it is not working. It is working for all test cases except for the cases where "limit" is 100000 and all values are in lakhs or similar scenerios. Can anyone explain! please.
Scanner scanner = new Scanner(System.in);
int limit = scanner.nextInt();
int max = 0;
int count = 0;
for(int i = 0; i < limit; i++ ){
int value = scanner.nextInt();
if(value > max) {
max = value;
count = 1;
}
else if(value == max){
count++;
}
}
System.out.print(count);
scanner.close();
}