Start from the second element , move from right to left and construct the jumps array where jumps [ i ] represents minimum number of jumps needed to reach arr [ m - 1 ] from arr [ i ]
for ( i = n - 2 ; i >= 0 ; i -- ) {