Maximize subsequences having array elements not exceeding length of the subsequence | Function to calculate the number of subsequences that can be formed ; Stores the number of subsequences ; Iterate over the map ; Count the number of subsequences that can be formed from key ; Number of occurrences of x . first which are left ; Return the number of subsequences ; Function to create the maximum count of subsequences that can be formed ; Stores the frequency of arr [ ] ; Update the frequency ; Print the number of subsequences ; Given array arr [ ] ; Function Call
function No_Of_subsequences ( mp ) { var count = 0 ; var left = 0 ; mp . forEach ( ( value , key ) => { value += left ; count += ( value / key ) ; left = value % key ; } ) ; return count ; } function maximumsubsequences ( arr , n ) { var mp = new Map ( ) ; for ( var i = 0 ; i < n ; i ++ ) { if ( mp . has ( arr [ i ] ) ) mp . set ( arr [ i ] , mp . get ( arr [ i ] ) + 1 ) else mp . set ( arr [ i ] , 1 ) ; } document . write ( No_Of_subsequences ( mp ) ) ; } var arr = [ 1 , 1 , 1 , 1 ] ; var N = arr . length ; maximumsubsequences ( arr , N ) ;