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.
- Prepare
- Algorithms
- Warmup
- Birthday Cake Candles
- Discussions
Birthday Cake Candles
Birthday Cake Candles
Sort by
recency
|
5386 Discussions
|
Please Login in order to post a comment
Java + based
def birthdayCakeCandles(candles): # Write your code here result = 0 for num in candles: if candles.count(candles[num]) > 1: result +=1 return result
That was a clear and simple explanation of the “Birthday Cake Candles” problem. I like how you broke down the logic of finding the tallest candle and counting its occurrences — it really helps beginners understand the reasoning behind the code instead of just following it. It’s interesting how such a basic problem reinforces array traversal and comparison concepts. By the way, have you tried optimizing it using built-in functions or a single-pass approach for larger datasets?
Created OrderedTreeSet to remove the duplicates then find the max element from the set, then find the count of occourence in the provided list.