-
Notifications
You must be signed in to change notification settings - Fork 0
/
birthdayCakeCandles.java
56 lines (35 loc) · 1.24 KB
/
birthdayCakeCandles.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package HackerRank2;
import java.util.Scanner;
public class birthdayCakeCandles {
public static void main(String[] args) {
/*
HACKERRANK ALGORİTMA :
BOYUTU VE KENDİSİ VERİLEN DİZİNİN İCİNDEKİ EN BÜYÜK SAYININ KAC TANE OLDUĞUNU BULACAĞIZ.
INPUT :
4 ---> DİZİ BOYUTU
3 7 2 7 ---> DİZİ
OUTPUT :
2 ---> ÇÜNKÜ DİZİNİN EN BÜYÜK ELEMANI 7. VE BU ELEMAN DİZİDE 2 ADET BULUNUYOR.
HACKERRANK LİNKİ : https://www.hackerrank.com/challenges/birthday-cake-candles/problem?isFullScreen=true
*/
Scanner input = new Scanner(System.in);
int sizeOfArray = input.nextInt();
int numbers[] = new int[sizeOfArray];
for (int counter = 0; counter < numbers.length; counter++) {
numbers[counter] = input.nextInt();
}
int bigger = Integer.MIN_VALUE;
for (int counter = 0; counter < numbers.length; counter++) {
if (numbers[counter] > bigger) {
bigger = numbers[counter];
}
}
int howManyBigger = 0;
for (int counter = 0; counter < numbers.length; counter++) {
if (bigger == numbers[counter]) {
howManyBigger++;
}
}
System.out.println(howManyBigger);
}
}