hello @Yash5646
if we are currently at i.
then using i we can clearly cover
[i…i+a[i]] range of indices, so what should be our next step from here(from i )?
we need to jump to that index among [i…i+a[i] ] , that will expand the range/reachability furthur, now which is the best best candidate?
it should be maximum among a[j] where j=[i…i+a[i] ] right?
now while implementation we need to take care of cases where no solution exist ( u r not handling). while making a jump we need to make sure i+jump distance not exceed the indices range (otherwise it will give segfault, u r not handing inside the inner loop).
check this for clarity- >link