Does this question want the solution according to greedy approach?
Example:
Test case 1
4
1 2 3 4
Greedy Approach - Piyush picks 4, Namit picks 3, Piyush picks 2 , Namit picks 1
Sum with Piyush = 6
Other possible scenario - Piyush picks 4 , Namit picks 1, Piyush picks 3 , Namit picks 2
Sum with piyush = 7
the answer according to the question should be 6, which is only possible if following greedy approach
Test Case 2:
4
4 15 3 2
If we go for greedy approach here we will get the wrong answer.
What approach is to be followed?