Minimum_Jumps_Required


what is the mistake in my code

ok, so the issue is in the cases where it does hit a case where arr[i] == 0
so in that case, it returns INT_MAX and then adds to it, so that circling property of integers comes into play and it becomes INT_MIN and ans is set to that and that is the value that is returned


so in this solution i have set it to n+1 and then later u can check if the returned answer is n+1 you can print INT_MAX although it passes the test cases without the INT_MAX as well

the logic behind n+1 was
i could not use n because what if all the numbers are 1
in that case the maximum jumps are n so it has to be atleast 1 greater than that

1 Like