Ugh, I hated this one, mainly because I took a completely wrong approach at first in an effort to be very fast. It was fast alright but could I get it to produce the right answer?!
Ali Spittel's stack solution is beautiful.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.