Minimum Jumps Required(Wrong Answer)

My code fails on the test case. It runs fine on the sample test cases. Can you suggest a condition where it doesn’t work?
Here’s the link to my code

The approach you are using in your code is bit wrong, basically you have to create a 1-D dp array, and check the following conditions, :
if(n==0 || ar[0]==0)
{
return INT_MAX;
}
Initialize first element of dp array as 0, then run loop from 1 to n and do the following :

	jumps[i]=INT_MAX;
	for(j=0;j<i;j++)
	{
		if(i<=j+ar[j] && jumps[j]!=INT_MAX)
		{
			jumps[i]=min(jumps[i],jumps[j]+1);
			break;
		}
	}

Make changes in your code accordingly… and then try to submit…

Can you explain why the approach that I am using is wrong?

The approach you are using is not producing correct output for all test cases, since dp array that you are building is not having correct values., thus I would suggest you to plz change your code accordingly,