Make N pairs from Array as ( X , Y ) coordinate point that are enclosed inside a minimum area rectangle | C # program for the above approach ; Function to make N pairs of coordinates such that they are enclosed in a minimum area rectangle with sides parallel to the X and Y axes ; A variable to store the answer ; For the case where the maximum and minimum are in different partitions ; For the case where the maximum and minimum are in the same partition ; Return the answer ; Driver code ; Given Input ; Function call
using System ; class GFG { public static int minimumRectangleArea ( int [ ] A , int N ) { int ans ; Array . Sort ( A ) ; ans = ( A [ N - 1 ] - A [ 0 ] ) * ( A [ 2 * N - 1 ] - A [ N ] ) ; for ( int i = 1 ; i < N ; i ++ ) ans = Math . Min ( ans , ( A [ 2 * N - 1 ] - A [ 0 ] ) * ( A [ i + N - 1 ] - A [ i ] ) ) ; return ans ; } public static void Main ( String [ ] args ) { int [ ] A = { 2 , 4 , 1 , 5 , 3 , 6 , 7 , 8 } ; int N = A . Length ; N = ( int ) N / 2 ; Console . Write ( minimumRectangleArea ( A , N ) ) ; } }