You are viewing a single comment's thread. Return to all comments →
**1.with Extension function - **
var maxHeightCandle = candles.maxOrNull() var maxHeightCandleCount = 0 for (candle in candles) { if (candle == maxHeightCandle) { maxHeightCandleCount++ } } return maxHeightCandleCount
**2. without Extension function - **
var maxHeightCandle = candles[0] var maxHeightCandleCount = 0 for (candle in candles) { if (candle > maxHeightCandle) { maxHeightCandle = candle maxHeightCandleCount = 1 } else if (candle == maxHeightCandle) { maxHeightCandleCount++ } } return maxHeightCandleCount
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 →
Solution in Kotlin -
**1.with Extension function - **
**2. without Extension function - **