I got a question in phone screening, can anyone please give the optimal solution.
input : An array will contain integer elements and their doubles in randomized indices. need to write a function to return the original array. ( only the original elements and not doubles, duplicates and negatives can also be there), if the input is invalid then just throw exception.
ex:
input: [1, 6, 4, 3, 2, 2]
output: [1, 2, 3]
Note: input array contains 1, 2, 3 and 1x2, 2x2 and 3x2
Thanks in advance.