Hacker News new | ask | show | jobs
by muxxa 4612 days ago
For a single pass from left to right, I think you need to maintain a counter for each y-value:

http://codepad.org/W16O9vUB

I actually think this is a good interview question, as playing devils' advocate and coming up with testcases that will break your initial code is a key programming skill, rather than assuming it is done and moving along.