You are viewing a single comment's thread. Return to all comments →
TYPESCRIPT function birthdayCakeCandles(candles: number[]): number { const count = new Map(); candles.sort((a,b) => b-a); for(let can of candles){ let prevCount = count.get(can) || 0; count.set(can,prevCount + 1); } console.log(count.get(candles[0])); return count.get(candles[0])
}
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Birthday Cake Candles
You are viewing a single comment's thread. Return to all comments →
TYPESCRIPT function birthdayCakeCandles(candles: number[]): number { const count = new Map(); candles.sort((a,b) => b-a); for(let can of candles){ let prevCount = count.get(can) || 0; count.set(can,prevCount + 1); } console.log(count.get(candles[0])); return count.get(candles[0])
}