Bloomberg interview question

coding problem: subway ticketing problem