Infosys Interview Question

should keep track of the time