Infosys Interview Question

I was given a puzzle to solve.