Question: You are given an array of n integers, divide the set into two subsets of n/2 sizes each such that the difference of the sum


You are given an array of n integers, divide the set into two subsets of n/2 sizes each such that the difference of the sum of two subsets is as minimum as possible. If n is even, then sizes of two subsets must be strictly n/2 and if n is odd, then the size of one subset must be (n1)/2 and size of another subset must be (n+1)/2 1. limport java.util.*; class Testclass 3{ void tugofWar(int arr[]) \{ //write your code here \} public static void main(String[] args) \{ TestClass obj = new TestClass () ; Scanner in = new Scanner(System.in); int n=in. nextInt(); int arr []= new int [n]; for (int i=0;i
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
