Longest increasing sub | C # implementation to find the longest increasing subsequence in repeating element of array ; Function to find the LCS ; Loop to create frequency array ; Driver code
using System ; using System . Collections . Generic ; class GFG { static int findLCS ( int [ ] arr , int n ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . ContainsKey ( arr [ i ] ) ) { mp [ arr [ i ] ] = mp [ arr [ i ] ] + 1 ; } else { mp . Add ( arr [ i ] , 1 ) ; } } return mp . Count ; } public static void Main ( String [ ] args ) { int n = 3 ; int [ ] arr = { 3 , 2 , 1 } ; Console . Write ( findLCS ( arr , n ) ) ; } }