noy getting how to form the logic
Can u plz help on how to approach this question
int jumps = 0, curEnd = 0, curFarthest = 0;
for (int i = 0;i<nums.size()-1;i++) {
curFarthest = max(curFarthest, i + nums[i]);
if (i == curEnd) {
jumps++;
curEnd = curFarthest;
}
}
return jumps;
I think this code snippet would help you.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.