I am Unable to understand

Can you please explain the logic for this pattern.

@rajharsh865 here simple code for reference debug to understand the logic


i hope its clear if yes dont forget to mark doubt resolved and hit like :smiley: