Compare temp [ a [ i ] ] with distance from its previous occurence and store the maximum
temp [ a [ i ] ] = Math . max ( temp [ a [ i ] ] , i - mp [ a [ i ] ] ) ; mp . set ( a [ i ] , i ) ; } for ( var i = 1 ; i <= n ; i ++ ) {