Solution for Box InterviewStreet challenge (https://box.interviewstreet.com/challenges/dashboard/#problems)