Infosys Interview Question

They asked me to solve a puzzle