GirnarSoft Interview Question

it was a puzzle on coding