C++ :
int birthdayCakeCandles(vector<int> ar) {
int max = 0, noOfCandle = 0;
for(int i = 0; i < ar.size(); i++){
if(ar[i] > max){
max = ar[i];
}
}
for(int j = 0; j < ar.size(); j++){
if(ar[j] == max){
noOfCandle++;
}
}
return noOfCandle;
}
Explanation:
There are 2 loops in this function. Basically this function is a combination of a findMax function and a countMax function. The first loop finds the max number in the vector, and the second loop counts the times max number appears in the vector.