Split array into minimum number of subsets such that elements of all pairs are present in different subsets at least once | Java program to implement the above approach ; 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
import java . util . * ; class GFG { static int MinimumNoOfWays ( int arr [ ] , int n ) { int mini_no_of_ways ; if ( n % 2 == 0 ) { mini_no_of_ways = n / 2 ; } else { mini_no_of_ways = n / 2 + 1 ; } return mini_no_of_ways ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 4 , 2 , 1 , 5 } ; int N = arr . length ; System . out . print ( MinimumNoOfWays ( arr , N ) ) ; } }