Imagine you have an array of numbers, and someone creates a mysterious new array by doubling every element and then shuffling everything together. Your mission is to be a digital detective and reverse this process!
Given an array called changed, determine if it's actually a "doubled array" - meaning it was created by taking some original array, doubling each element, combining them, and shuffling. If it is, return the original array. If it's impossible, return an empty array.
Example: If the original array was [1, 3, 4], the doubled array would contain [1, 3, 4, 2, 6, 8] in some order (each original number plus its double).
The elements in your answer can be in any order - you just need to find what the original array could have been!
Input & Output
Constraints
- 1 โค changed.length โค 105
- 0 โค changed[i] โค 105
- The array length must be even for a valid doubled array