You are viewing a single comment's thread. Return to all comments →
I tried to mimic the test case 8. My solution didn't work either and its total hack!
function birthdayCakeCandles(ar) { const isEdge = typeof parseInt(inputString[0], 10) === 'number' && inputString.length === 2 && inputString[1].split(' ').length > 0 ? true : false; const size = isEdge ? parseInt(inputString[0], 10) : ar.length; const tallest = ar.sort().reverse()[0]; const output = ar.reduce((acc, n) => { acc = n === tallest ? acc + 1 : acc; return acc; }, 0); console.log(output > size ? size: output) return output > size ? size : output; }
I'm not sure what's going on either.
I tried this case:
200 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000
It works and gives the answer 200 (there is 203 entries). however using the other one it crashes. The text file is too big to test in the editor.
[EDIT]
Figured it out
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 →
I tried to mimic the test case 8. My solution didn't work either and its total hack!
I'm not sure what's going on either.
I tried this case:
It works and gives the answer 200 (there is 203 entries). however using the other one it crashes. The text file is too big to test in the editor.
[EDIT]
Figured it out