<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>

class Solution:
    def findOriginalArray(self, changed: List[int]) -> List[int]:
        ll = len(changed)
        if ll % 2 != 0: return []
        result, hashmap = [], {}
        # Push numbers in hashmap {number: count}
        for n in changed: hashmap[n] = 1 + hashmap.get(n, 0)
        for num in sorted(hashmap.keys()):

            if hashmap[num] > 0: # this condition means we already get all count of that number
                # 0*2 = 0 so 0 is  twice the value of 0 so if the count of so we insert 2 zeros in list as one zero
                # if there was 3 zeros we only insert 2 to the result
                if num == 0:
                    # we can put a condition here that if it found a odd count of zeros return emty list
                    if hashmap[num] % 2 != 0: return []
                    result += [0] * (hashmap[num] // 2)
                    hashmap[num] = 0
                # if the number anything else
                elif hashmap.get(num * 2, False):
                    if hashmap[num] > hashmap[num*2]: return []
                    count = hashmap[num]
                    hashmap[num * 2] -= count
                    # insert the number with all counts into the result
                    result += [num] * count 

        return result if len(result) == ll / 2 else []
870