<p>Alice and Bob have a different total number of candies. You are given two integer arrays <code>aliceSizes</code> and <code>bobSizes</code> where <code>aliceSizes[i]</code> is the number of candies of the <code>i<sup>th</sup></code> box of candy that Alice has and <code>bobSizes[j]</code> is the number of candies of the <code>j<sup>th</sup></code> box of candy that Bob has.</p>

<p>Since they are friends, they would like to exchange one candy box each so that after the exchange, they both have the same total amount of candy. The total amount of candy a person has is the sum of the number of candies in each box they have.</p>

<p>Return a<em>n integer array </em><code>answer</code><em> where </em><code>answer[0]</code><em> is the number of candies in the box that Alice must exchange, and </em><code>answer[1]</code><em> is the number of candies in the box that Bob must exchange</em>. If there are multiple answers, you may <strong>return any</strong> one of them. It is guaranteed that at least one answer exists.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> aliceSizes = [1,1], bobSizes = [2,2]
<strong>Output:</strong> [1,2]
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> aliceSizes = [1,2], bobSizes = [2,3]
<strong>Output:</strong> [1,2]
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> aliceSizes = [2], bobSizes = [1,3]
<strong>Output:</strong> [2,3]
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= aliceSizes.length, bobSizes.length &lt;= 10<sup>4</sup></code></li>
	<li><code>1 &lt;= aliceSizes[i], bobSizes[j] &lt;= 10<sup>5</sup></code></li>
	<li>Alice and Bob have a different total number of candies.</li>
	<li>There will be at least one valid answer for the given input.</li>
</ul>

class Solution {
    public:
        vector<int> fairCandySwap(vector<int>& aliceSizes, vector<int>& bobSizes) {
                int sm1 = 0;
                        int sm2 = 0;
                                for(int s : aliceSizes) {
                                            sm1+=s;
                                                    }
                                                            
                                                                    int mpp[100000+4];
                                                                            memset(mpp, 0, sizeof(mpp));
                                                                                    for(int s : bobSizes) {
                                                                                                sm2+=s;
                                                                                                            mpp[s]++;
                                                                                                                    }
                                                                                                                            
                                                                                                                                    int sm = (sm2 + sm1);
                                                                                                                                            if((sm%2) == 1) {
                                                                                                                                                        return {};
                                                                                                                                                                }
                                                                                                                                                                        
                                                                                                                                                                                sm/=2;
                                                                                                                                                                                        
                                                                                                                                                                                                for(int s : aliceSizes) {
                                                                                                                                                                                                            int new_alice_sm = sm1 - s;
                                                                                                                                                                                                                        if(new_alice_sm >= sm) {
                                                                                                                                                                                                                                        continue;
                                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                            int extra_wt_needed = sm - new_alice_sm;
                                                                                                                                                                                                                                                                                        if(extra_wt_needed > (1e5)) {
                                                                                                                                                                                                                                                                                                        continue;
                                                                                                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                                                                                                                if(mpp[extra_wt_needed] != 0) {
                                                                                                                                                                                                                                                                                                                                                return {s, extra_wt_needed};
                                                                                                                                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                                    return {};
                                                                                                                                                                                                                                                                                                                                                                                        }
                                                                                                                                                                                                                                                                                                                                                                                        };

42300