int minJumps(int arr[], int n){
// Your code here
int count=1;
count+=arr[0];
int i=1;
while(count<=n-1)
{
count+=arr[count-1];
if(arr[count-1]==0&&count!=n-1)
{
return -1;
}
i++;
}
return i;
}
This submission of mine gives TLE according to me this is a O(n) solution.
Pls help me out to solve this problem