Birthday Cake Candles

Sort by

recency

|

5296 Discussions

|

  • + 0 comments

    def birthdayCakeCandles(candles): return candles.count(max(candles))

  • + 0 comments
    def birthdayCakeCandles(candles):
        m = max(candles)
        return len(list(filter(lambda i: candles[i] == m, candles)))
    
  • + 0 comments
    public static int birthdayCakeCandles(List<Integer> candles) {
        int maxNumber = Integer.MIN_VALUE;
        int can = 0;
    
        for(int i: candles){
            if(i > maxNumber){
                maxNumber = i;
            }
        }
    
        for(int j : candles){
            if(j == maxNumber){
                can++;
            }
        }
    
        return can;
    }
    
  • + 0 comments

    Python oneliner:

    def birthdayCakeCandles(candles):
        return candles.count(max(candles))
    
  • + 0 comments

    Typescript:

    let candle_height = 0;
    let tallest_candle = 0;
    for (let i = 1; i < candles.length; i++) {
       if (candles[i] > tallest_candle) {
          tallest_candle = candles[i];
       }
    }
    for (let i = 0; i < candles.length; i++) {
       if(Number(tallest_candle) == Number(candles[i])){
          candle_height += 1;
       }
    }
    return candle_height;