I was unable to solve it
Given an array nums of n integers. Delete a subsequence of length k (where k =n/3) from the array. Let's call the array B after deleting the subsequence. Now Geek will be happy if the array B can be divided into 2 subarray of equal length such that difference between sum of elements of first subarray and sum of elements of second subarray is minimum possible.
Geek asked you to make him happy.
Note: It is guaranted that n is divisible by 3.
Example 1: Input: nums = {7,9,5,7,2,1} Output: 3
Explanation: Delete the nums[2] and nums[6].
Then array B will be- {7, 5, 7, 2}.
Now the array can be divided into {7,5} and {7,2}.
So the answer will be (7+5)-(7+2) = 3.
Example 2: Input: nums = {5,6,3} Output: -1
Explanation: Delete nums[3]. Then array B will be- {5,6}.
Now the array can be divided into {5} and {6}. So the answer will be 5-6 = -1.
Contraints: 1<=n<=3*10^5 1<=nums[i]<=10^9
The only hint i got later is to use priority queue
Please share your logic or Code