We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Did you try using c++ std::sort(ar.begin(), ar.end()); ? I did and it worked flawlessly.
int birthdayCakeCandles(int n, vector<int> ar) {
// Complete this function
sort(ar.begin(), ar.end());
int max = ar[ar.size() -1];
int count = 0;
for(auto num : ar) {
if(num == max) ++count;
}
return count;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Birthday Cake Candles
You are viewing a single comment's thread. Return to all comments →
}