<p>An integer array <code>original</code> is transformed into a <strong>doubled</strong> array <code>changed</code> by appending <strong>twice the value</strong> of every element in <code>original</code>, and then randomly <strong>shuffling</strong> the resulting array.</p>

<p>Given an array <code>changed</code>, return <code>original</code><em> if </em><code>changed</code><em> is a <strong>doubled</strong> array. If </em><code>changed</code><em> is not a <strong>doubled</strong> array, return an empty array. The elements in</em> <code>original</code> <em>may be returned in <strong>any</strong> order</em>.</p>

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

<pre>
<strong>Input:</strong> changed = [1,3,4,2,6,8]
<strong>Output:</strong> [1,3,4]
<strong>Explanation:</strong> One possible original array could be [1,3,4]:
- Twice the value of 1 is 1 * 2 = 2.
- Twice the value of 3 is 3 * 2 = 6.
- Twice the value of 4 is 4 * 2 = 8.
Other original arrays could be [4,3,1] or [3,1,4].
</pre>

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

<pre>
<strong>Input:</strong> changed = [6,3,0,1]
<strong>Output:</strong> []
<strong>Explanation:</strong> changed is not a doubled array.
</pre>

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

<pre>
<strong>Input:</strong> changed = [1]
<strong>Output:</strong> []
<strong>Explanation:</strong> changed is not a doubled array.
</pre>

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

<ul>
	<li><code>1 &lt;= changed.length &lt;= 10<sup>5</sup></code></li>
	<li><code>0 &lt;= changed[i] &lt;= 10<sup>5</sup></code></li>
</ul>

from collections import Counter
class Solution:
    def findOriginalArray(self, changed: List[int]) -> List[int]:
        # if len(changed)%2 != 0:
        #     return []
        
        # zero_arr, odd_arr, even_arr = [], [], []
        # for num in changed:
        #     if num == 0:
        #         zero_arr.append(num)
        #     elif num%2 != 0:
        #         odd_arr.append(num)
        #     else:
        #         even_arr.append(num)
        # #print(zero_arr, odd_arr, even_arr)       
        # if ((len(zero_arr)%2 != 0)  or len(odd_arr) > len(even_arr)):
        #     return []
        # set_even = set(even_arr)
        # for num in odd_arr:
        #     if num * 2 not in set_even:
        #         return []
        #     else:
        #         even_arr.remove(num *2)
        # if not even_arr:
        #     return [0]*(len(zero_arr)//2) + odd_arr
        
        # if len(even_arr) %2 != 0:
        #     return []
        # even_arr = sorted(even_arr)
        # set_even2 = set(even_arr[len(even_arr)//2:])
        # for i in range(len(even_arr)//2):
        #     if even_arr[i] *2 not in set_even2:
        #         return []
        #     else:
        #         odd_arr.append(even_arr[i])
        # return [0]*(len(zero_arr)//2) + odd_arr if zero_arr else odd_arr
        A = changed
        lookup = Counter(A)
        #print(lookup)
        if 0 in lookup and lookup[0]%2==1:
            return []
        for x in sorted(lookup):
            if lookup[x] > lookup[2*x]:
                return []
            lookup[2*x]-=lookup[x] if x else lookup[x]/2
        #print(lookup)
        ans = []
        for key_, val in lookup.items():
            if val:
                ans += [key_]*int(val)
        return ans
34100