last index of a [ i ] - 1
lastIndex = mp [ a [ i ] - 1 ] - 1 NEW_LINE dp [ i ] = 1 + dp [ lastIndex ] NEW_LINE else : NEW_LINE dp [ i ] = 1 NEW_LINE mp [ a [ i ] ] = i + 1 NEW_LINE maximum = max ( maximum , dp [ i ] ) NEW_LINE return maximum NEW_LINE