➽ Problem:-
https://www.hackerrank.com/challenges/birthday-cake-candles/problem
➽ Solution:-
import
java.util.*;
import
java.io.*;
public class
Solution
{
public static void main(String args[])
{
int N;
Scanner sc = new Scanner(System.in);
N = sc.nextInt();
int arr[] = new int[N];
for(int i=0;i<N;i++)
{
arr[i] = sc.nextInt();
}
int height=0,count=0;
for(int i=0;i<N;i++)
{
if(arr[i]>height)
{
height = arr[i];
count = 1;
}
else if(arr[i] == height)
{
count++;
}
}
System.out.println(count);
}
}
0 Comments
Please do not enter any spam link in the comment section.