Minimum jumps dp

my code is showing wrong answer for every test case
plz identify the mistake and make changes and let me know my mistake

problem : https://online.codingblocks.com/app/player/39658/content/77394/5284/code-challenge

code : https://ide.codingblocks.com/s/210028

plz reply asap

bool canJump(vector& arr) {
int n=arr.size();
if(n==0)
return true;
if(n==1)
return true;
//int jump = arr[0];
int maxreach = arr[0];
for(int i=1; i<n; ++i)
{
if(maxreach >= i)
{
maxreach = max(maxreach, arr[i]+i);
}
if(maxreach >=n-1)
{
return true;
}
if(maxreach<i)
{
return false;
}
}
if(maxreach >=n-1)
{
return true;
}
return false;
}
hey, u can refer to this function for the correct answer

the mistake in your code is in ur for loop
consider
3 2 0 4 4
i starts at 0
index + v[i] is 3
now i goes to 1 and index + v[i] is 2
now i is 2 and index + v[i] is 0 and the loop ends but it should take another step forward since from 0th index it can go to 3rd index which is 4

hey @sengarankit98 please mark this as resolved if your doubt is solved,