public static long jump(int arr[]){
long jumps=0;
long currEnd=0;
long fartEnd=0;
for(int i=0;i<arr.length;i++){
fartEnd=Math.max(fartEnd,i+arr[i]);
if(i==currEnd){
jumps++;
currEnd=fartEnd;
}
}
return jumps;
}
Not passing a test case
i see you’ve already corrected you mistake and scored 100 .if there 's no other doubt please mark this resolved
but please check my above code, whats the error in this code
for test case like
1
392
29 44 44 19 23 47 33 73 16 95 26 66 21 18 51 81 37 35 88 62 60 79 29 97 46 30 39 2 84 93 56 34 7 5 1 52 17 39 10 83 63 73 21 56 31 38 7 99 43 38 95 82 90 40 32 76 16 99 1 35 44 46 83 17 15 79 24 89 70 91 25 37 36 36 69 50 95 82 55 98 76 34 80 97 49 80 86 23 18 20 56 57 22 28 39 34 67 20 84 4 76 54 80 91 66 38 16 1 85 60 68 46 45 81 58 54 52 88 95 53 34 10 42 71 98 96 16 0 6 95 75 17 34 11 45 52 13 93 31 0 54 75 91 77 89 22 30 74 56 78 30 71 71 67 52 89 93 36 73 24 1 51 3 21 61 48 97 88 2 19 66 12 96 31 1 4 76 13 84 56 63 67 69 9 1 9 66 64 78 1 76 70 15 54 69 84 80 80 12 25 16 94 29 8 86 64 49 10 35 25 92 1 55 72 58 18 20 99 83 88 97 80 27 93 76 51 88 9 95 87 5 44 67 36 43 5 9 10 22 57 88 16 18 88 92 71 78 42 57 48 25 96 43 87 95 74 37 38 98 80 55 17 94 52 96 19 89 19 63 69 7 5 22 21 38 34 8 46 17 50 64 54 62 93 83 76 88 80 80 95 90 19 18 82 65 11 38 94 67 81 55 9 29 3 14 28 87 99 89 7 62 2 91 92 87 31 33 93 17 40 16 46 71 87 58 62 43 9 89 29 61 92 6 94 20 23 6 37 18 82 27 0 39 77 48 58 80 61 86 56 28 37 50 3 38 55 55 66 20 23 74 12 11 59 46 56 8 28 1 1 3 23 60 68 10 84 42 24 36 47 45 44 39 80 16 91 75 33 72 36 27 56
343
your code gives 6 but the correct answer will be 5