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 hereMap<Integer,Integer>map=newHashMap<>();intmaxValue=0;for(inti=0;i<candles.size();i++){if(map.containsKey(candles.get(i))){intcurrentValue=map.get(candles.get(i))+1;map.put(candles.get(i),currentValue);if(currentValue>maxValue){maxValue=currentValue;}}else{map.put(candles.get(i),1);}}returnmaxValue;}
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 →