Maximize the division result of Array using given operations | Java implementation to maximize the result of division of the given array elements ; Function to find the max result ; Sort the array in descending order ; Loop to divide in this order arr [ 0 ] / ( arr [ 1 ] / arr [ 2 ] / ... . arr [ n - 2 ] / arr [ n - 1 ] ) ; Return the final result ; Driver code
import java . util . * ; class GFG { static float maxDivision ( Integer arr [ ] , int n ) { Arrays . sort ( arr , Collections . reverseOrder ( ) ) ; float mxdiv = arr [ 1 ] ; for ( int i = 2 ; i < n ; ++ i ) mxdiv = mxdiv / arr [ i ] ; return arr [ 0 ] / mxdiv ; } public static void main ( String [ ] args ) { Integer arr [ ] = { 100 , 1000 , 10 , 2 } ; int n = arr . length ; System . out . print ( ( int ) maxDivision ( arr , n ) ) ; } }