Split array into minimum number of subsets such that elements of all pairs are present in different subsets at least once | C ++ program to 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; 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 ; } int main ( ) { int arr [ ] = { 3 , 4 , 2 , 1 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << MinimumNoOfWays ( arr , N ) ; return 0 ; }