Update the maximum length of subsequence ending at element is a [ i ] in Dictionary
if ( map . ContainsKey ( a [ i ] ) ) { map [ a [ i ] ] = Math . Max ( map [ a [ i ] ] + 1 , dp [ i ] ) ; ; } else { map . Add ( a [ i ] , Math . Max ( 1 , dp [ i ] ) ) ; } }