Maximize the division result of Array using given operations | C # 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 readonly result ; Driver code
using System ; class GFG { static float maxDivision ( int [ ] arr , int n ) { Array . Sort ( arr ) ; Array . Reverse ( arr ) ; 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 ) { int [ ] arr = { 100 , 1000 , 10 , 2 } ; int n = arr . Length ; Console . Write ( ( int ) maxDivision ( arr , n ) ) ; } }