Can you please tell where am I going wrong in this question?
Doubt in execution of a function
your code lacks at several points
refer this code
i have added step wise comments all corner cases are talked about in the code
u`ll understand where u have gone wrong