text: Maximize count of Decreasing Subsequences from the given Array | C # program for rearrange array to generate maximum decreasing subsequences ; Function to count maximum subsequence ; Stores the frequency of array elements ; Stores maximum frequency ; Update frequency of A [ i ] ; Update maximum subsequences ; Print the result ; Driver Code
code: using System ; using System . Collections . Generic ; class GFG { public static void Maximum_subsequence ( int [ ] A , int N ) { Dictionary < int , int > frequency = new Dictionary < int , int > ( ) ; int max_freq = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( frequency . ContainsKey ( A [ i ] ) ) { frequency [ A [ i ] ] = frequency [ A [ i ] ] + 1 ; } else { frequency . Add ( A [ i ] , 1 ) ; } } foreach ( KeyValuePair < int , int > it in frequency ) { if ( ( int ) it . Value > max_freq ) { max_freq = ( int ) it . Value ; } } Console . WriteLine ( max_freq ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 2 , 6 , 5 , 2 , 4 , 5 , 2 } ; int N = arr . Length ; Maximum_subsequence ( arr , N ) ; } }