text: Maximize count of Decreasing Subsequences from the given Array | 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: function Maximum_subsequence ( A , N ) { var frequency = new Map ( ) ; var max_freq = 0 ; for ( var i = 0 ; i < N ; i ++ ) { if ( frequency . has ( A [ i ] ) ) frequency . set ( A [ i ] , frequency . get ( A [ i ] ) + 1 ) else frequency . set ( A [ i ] , 1 ) ; } frequency . forEach ( ( value , key ) => { if ( value > max_freq ) { max_freq = value ; } } ) ; document . write ( max_freq ) ; } var arr = [ 5 , 2 , 6 , 5 , 2 , 4 , 5 , 2 ] ; var N = arr . length ; Maximum_subsequence ( arr , N ) ;