Algorithm logic and its working

unable to understand the algorithm logic

Himanshu, can you send the question for which you are not able to understand logic