Split array into two subarrays such that difference of their maximum is minimum | C # Program to split a given array such that the difference between their maximums is minimized . ; Sort the array ; Return the difference between two highest elements ; Driver code
using System ; class GFG { static int findMinDif ( int [ ] arr , int N ) { Array . Sort ( arr ) ; return ( arr [ N - 1 ] - arr [ N - 2 ] ) ; } public static void Main ( ) { int [ ] arr = { 7 , 9 , 5 , 10 } ; int N = arr . Length ; Console . Write ( findMinDif ( arr , N ) ) ; } }