text: Maximize count of Decreasing Subsequences from the given Array | C ++ Program to implement the above approach ; Function to count maximum subsequence ; Stores the frequency of array elements ; Stores max frequency ; Update frequency of A [ i ] ; Update max subsequence ; Print the count ; Driver Code
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; void Maximum_subsequence ( int A [ ] , int N ) { unordered_map < int , int > frequency ; int max_freq = 0 ; for ( int i = 0 ; i < N ; i ++ ) { frequency [ A [ i ] ] ++ ; } for ( auto it : frequency ) { if ( it . second > max_freq ) { max_freq = it . second ; } } cout << max_freq << endl ; } int main ( ) { int arr [ ] = { 5 , 2 , 6 , 5 , 2 , 4 , 5 , 2 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; Maximum_subsequence ( arr , N ) ; return 0 ; }