Ciklum Interview Question

Puzzle from GFG top 50 puzzle