Goibibo Interview Question

Something about door open close problem.