last index of a [ i ] - 1
var lastIndex = mp . get ( a [ i ] - 1 ) - 1 ; dp [ i ] = 1 + dp [ lastIndex ] ; } else dp [ i ] = 1 ; mp . set ( a [ i ] , i + 1 ) ; maximum = Math . max ( maximum , dp [ i ] ) ; } return maximum ; }