A solution to an interview question I ran out of time on.