Maximize sum of second minimums in all quadruples of a given array | Function to find maximum possible sum of second minimums in each quadruple ; Sort the array ; Add the second minimum ; Prlet maximum possible sum ; Given array ; Size of the array
function maxPossibleSum ( arr , N ) { arr . sort ( ) ; let sum = 0 ; let j = N - 3 ; while ( j >= 0 ) { sum += arr [ j ] ; j -= 3 ; } document . write ( sum ) ; } let arr = [ 7 , 4 , 5 , 2 , 3 , 1 , 5 , 9 ] ; let N = arr . length ; maxPossibleSum ( arr , N ) ;