Compare temp [ i ] with distance of its last occurence from the end of the array and store the maximum
if ( temp [ i ] != - 1 ) temp [ i ] = Math . max ( temp [ i ] , n - mp . getOrDefault ( i , 0 ) ) ; } }