<p>Given an integer array <code>nums</code>, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. You can return the answer in <strong>any order</strong>.</p>

<p>You must write an&nbsp;algorithm that runs in linear runtime complexity and uses&nbsp;only constant extra space.</p>

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

<pre>
<strong>Input:</strong> nums = [1,2,1,3,2,5]
<strong>Output:</strong> [3,5]
<strong>Explanation: </strong> [5, 3] is also a valid answer.
</pre>

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

<pre>
<strong>Input:</strong> nums = [-1,0]
<strong>Output:</strong> [-1,0]
</pre>

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

<pre>
<strong>Input:</strong> nums = [0,1]
<strong>Output:</strong> [1,0]
</pre>

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

<ul>
	<li><code>2 &lt;= nums.length &lt;= 3 * 10<sup>4</sup></code></li>
	<li><code>-2<sup>31</sup> &lt;= nums[i] &lt;= 2<sup>31</sup> - 1</code></li>
	<li>Each integer in <code>nums</code> will appear twice, only two integers will appear once.</li>
</ul>

mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
int get_rand(int a, int b)
{
    return a + rng()%(b-a+1);
};

class Solution {
public:
    vector<int> singleNumber(vector<int>& nums) {
        int id = get_rand(0, (int)nums.size()-1);
        int qt_left = 0, qt_right = 0;
        int xor_left = 0, xor_right = 0;
        for(int x: nums)
        {
            if(x <= nums[id])
                qt_left++, xor_left ^= x;
            else
                qt_right++, xor_right ^= x;
        }
        if(qt_left%2 == 0 && xor_left)
        {
            vector<int> left;
            for(int x: nums)
                if(x <= nums[id])
                    left.push_back(x);
            return singleNumber(left);
        }
        if(qt_right%2 == 0 && xor_right)
        {
            vector<int> right;
            for(int x: nums)
                if(x > nums[id])
                    right.push_back(x);
            return singleNumber(right);
        }
        return {xor_left, xor_right};
    }
};
13500