Infosys Interview Question

The puzzle was a difficult one.