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.
publicstaticintbirthdayCakeCandles(List<Integer>candles){// Write your code here// Optimized code// Time Complexity O(n) (Linear time)// Space Complexity O(1) (Constant space) Only two integer variables are used, regardless of input size.inttallestCandle=0;inttallestCount=0;for(Integeri:candles){if(i>tallestCandle){tallestCandle=i;tallestCount=0;}if(i==tallestCandle){tallestCount++;}}returntallestCount;}}
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 →
Java + based