Saturday, October 29, 2022

Birthday Cake Candles Problem(Hacker Rank)

 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
  1. Find the tallest candle.
  2. Count the number of tallest candles using linq.
  3. return result.


No comments:

Post a Comment

methods available in Dapper

  Dapper is a micro ORM library for .NET and .NET Core applications that allows you to execute SQL queries and map the results to objects. D...