text: Maximum number of pair reductions possible on a given triplet | Function to count the maximum number of pair reductions possible on a given triplet ; Convert them into an array ; Stores count of operations ; Sort the array ; If the first two array elements reduce to 0 ; Apply the operations ; Increment count ; Print the maximum count ; Given triplet
code: function maxOps ( a , b , c ) { let arr = [ a , b , c ] ; let count = 0 ; while ( 1 ) { arr . sort ( ) ; if ( ! arr [ 0 ] && ! arr [ 1 ] ) break ; arr [ 1 ] -= 1 ; arr [ 2 ] -= 1 ; count += 1 ; } document . write ( count ) ; } let a = 4 , b = 3 , c = 2 ; maxOps ( a , b , c ) ;