Infosys Interview Question

A puzzle was quite difficult