Skip to content

Practice Find Original Array From Doubled Array

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2007
LeetCode Problem

Find Original Array From Doubled Array

Problem Statement

An integer array original is transformed into a doubled array changed by appending twice the value of every element in original, and then randomly shuffling the resulting array. Given an array changed, return original if changed is a doubled array. If changed is not a doubled array, return an empty array. The elements in original may be returned in any order.

Source: Find Original Array From Doubled Array on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
changed = [1,3,4,2,6,8]
Output
[1,3,4]

# Example 2

Input
changed = [6,3,0,1]
Output
[]

# Example 3

Input
changed = [1]
Output
[]

Constraints

1 <= changed.length <= 10^5
0 <= changed[i] <= 10^5

Related LeetCode Problems

Practice more problems similar to Find Original Array From Doubled Array.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.