hash table to map the array element with the length of the longest subsequence of which it is a part of and is the last / first element of that subsequence
Dictionary < int , int > inc = new Dictionary < int , int > ( ) ; Dictionary < int , int > dcr = new Dictionary < int , int > ( ) ;