class Solution:
def findOriginalArray(self, changed: List[int]) -> List[int]:
ans = []
q = deque()
for num in sorted(changed):
if q and num == q[0]:
q.popleft()
else:
q.append(num * 2)
ans.append(num)
return [] if q else ans
leetcode
challenge
here is the link for the problem:
https://leetcode.com/problems/find-original-array-from-doubled-array/
Top comments (0)