Bloomberg Interview Question

coding problem: subway ticketing problem