Split array into minimum number of subsets such that elements of all pairs are present in different subsets at least once | Function to find minimum count of ways to split the array into two subset such that elements of each pair occurs in two different subset ; Stores minimum count of ways to split array into two subset such that elements of each pair occurs in two different subset ; If N is odd ; Driver code
function MinimumNoOfWays ( arr , n ) { var mini_no_of_ways ; if ( n % 2 == 0 ) { mini_no_of_ways = n / 2 ; } else { mini_no_of_ways = n / 2 + 1 ; } return parseInt ( mini_no_of_ways ) ; } var arr = [ 3 , 4 , 2 , 1 , 5 ] ; var N = arr . length ; document . write ( MinimumNoOfWays ( arr , N ) ) ;