304 North Cardinal St.
Dorchester Center, MA 02124

# Birthday Cake Candles Hacker Rank Solution – Queslers

## Problem: Birthday Cake Candles Hacker Rank Solution

Complete the function birthday cake candles in the editor below. It must return an integer representing the number of candles she can blow out.

birthday cake candles has the following parameter(s):

• ar: an array of integers representing candle heights

Input Format

The first line contains a single integer, n, denoting the number of candles on the cake. The second line contains n space-separated integers, where each integer i describes the height of candle I. The input format is very useful to get Birthday Cake Candles Solution in C language.

Constraints

• 1<=n<=10^5
• 1<=ar[i]<=10^7

Output Format

Return the number of candles that can be blown out on a new line.

Sample Input 0
4
3 2 1 3
Sample Output 0
2
Explanation 0

Explanation of Birthday Cake Candles Hackerrank Solution in C and C++ programming languages are below, this an only explanation of the above input. We have one candle of height 1, one candle of height 2, and two candles of height 3. Your niece only blows out the tallest candles, meaning the candles where height = 3. Because there are 2 such candles, we print 2 on a new line. Let move and try to understand the Birthday Cake Candles Code in C programming language.

### Birthday Cake Candles Hacker Rank Solution Using Python

``````#!/bin/python3

import math
import os
import random
import re
import sys

# Complete the birthdayCakeCandles function below.
def birthdayCakeCandles(ar):
c = 0
temp = ar
for i in range(1,len(ar)):
if ar[i] > temp:
temp = ar[i]
for i in range(0,len(ar)):
if ar[i] == temp:
c = c + 1
return c
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')

ar_count = int(input())

ar = list(map(int, input().rstrip().split()))

result = birthdayCakeCandles(ar)

fptr.write(str(result) + '\n')

fptr.close()``````

### Birthday Cake Candles Hacker Rank Solution Using Java

``````import java.io.*;
import java.util.*;

public class Solution {

public static void main(String[] args) {
Scanner in = new Scanner(System.in);

int n = in.nextInt();
int max = 0;
int sum = 0;
int num;
for(int i =0; i < n; i++){
num = in.nextInt();
if(num > max){
sum = 1;
max = num;
}else if(num == max){
sum++;
}
}
System.out.println(sum);
}
}``````

### Birthday Cake Candles Hacker Rank Solution Using C++

``````#include <iostream>

using namespace std;

int main() {

int n, maks = 0, kolko, x;

cin >> n;

for( int i=0; i<n; i++ ) {
cin >> x;

if( x > maks ) {
maks = x;
kolko = 1;
}
else if( x == maks )
kolko++;
}

cout << kolko;

return 0;
}``````

### Birthday Cake Candles Hacker Rank Solution Using C

``````#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main()
{
int n;
scanf("%d", &n);

int h, hm, c;
c = 0; hm = 0;

for (int idx = 0; idx < n; idx++)
{
scanf("%d", &h);

if (h > hm)
{
hm = h;
c = 1;
}
else if (h == hm)
{
c++;
}
}
printf("%d", c);

return 0;
}``````

### Birthday Cake Candles Hacker Rank Solution Using JavaScript

``````function processData(input) {
var inputs = (input.split("\n"));
var n = parseInt(inputs);
var str_candles = inputs.split(" ");
candles = []
for (var i=0; i<n; i++) {
candles.push(parseInt(str_candles[i]));
}
var greatest = Number.NEGATIVE_INFINITY;
var count = 0;
for (var i=0; i<n; i++) {
if (candles[i] > greatest) {
greatest = candles[i];
}
}
for (var i=0; i<n; i++) {
if (candles[i] == greatest) {
count += 1;
}
}
console.log(count);
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
_input += input;
});

process.stdin.on("end", function () {
processData(_input);
});``````
##### Birthday Cake Candles Hacker Rank Solution Review:

In our experience, we suggest you solve this Birthday Cake Candles Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

Birthday Cake Candles Hacker Rank Problem is available on Hacker Rank for Free, if you are stuck anywhere between a compilation, just visit Queslers to get Birthday Cake Candles Hacker Rank Solution.

##### Conclusion:

I hope this Birthday Cake Candles Hacker Rank Solution would be useful for you to learn something new from this problem. I hope this Python: Division Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Hacker Rank Problem & Solutions >>

Staircase Hacker Rank Solution

A Very Big Sum Hacker Rank Solution

Diagonal Difference Hacker Rank Solution

Nested Lists Hacker Rank Solution

Lists Hacker Rank Solution