Otherwise , get the value from the map and update left [ i ]
else { let tmp = map . get ( arr [ i ] ) ; left [ i ] = ( tmp . count ) * ( i - tmp . prevIndex ) + left [ tmp . prevIndex ] ; map . set ( arr [ i ] , new pair ( tmp . count + 1 , i ) ) ; } }