Tech Mahindra Interview Question

They asked puzzles as well.