Maximize count of subsets into which the given array can be split such that it satisfies the given condition | Function to count maximum subsets into which the given array can be split such that it satisfies the given condition ; Sort the array in decreasing order ; Stores count of subsets possible ; Stores count of elements in current subset ; Traverse the array arr [ ] ; Update size ; If product of the smallest element present in the current subset and size of current subset is >= K ; Update maxSub ; Update size ; Given array ; Size of the array ; Given value of X
function maxDivisions ( arr , N , X ) { arr . sort ( ) ; let maxSub = 0 ; let size = 0 ; for ( let i = 0 ; i < N ; i ++ ) { size ++ ; if ( arr [ i ] * size >= X ) { maxSub ++ ; size = 0 ; } } document . write ( maxSub + " " ) ; } let arr = [ 1 , 3 , 3 , 7 ] ; let N = arr . length ; let X = 3 ; maxDivisions ( arr , N , X ) ;