Did 1 leetcode today


Able to run the algo on paper and wrote down the javascript, not able to pass some test cases. so need to copy the answer.

My idea is similar, but the answer is much better. The idea is similar to tracking max number, but this time we have max1, max2, max3 (max1 is largest)

init all of them to null.

looping number array, if number is in maxs, skip. If there number > max1, we update all max1-3

if number > max2, update max2-3
then number > max3, update max3

last return statement is like this: return max3 == null ? max1 : max3;

Your Job Suck?
Get a Better Job
Add Comment