You are in charge of the cake for a child's birthday. You have decided the cake will have one candle for each year of their total age. They will only be able to blow out the tallest of the candles. Count how many candles are tallest.
Example
The maximum height candles are units high. There are of them, so return .
SOLUTION:
public static int birthdayCakeCandles(List<int> candles)
{
int max = candles.Max();
int result = candles.Count(x=>x==max);
return result;
}
Description
- Find the tallest candle.
- Count the number of tallest candles using linq.
- return result.
No comments:
Post a Comment