Counter problem

I’m still in doubt, why counter is used here?
any way of running code without using counter?

@pulkitmidha28
share your code link