Grokking Microsoft Coding Interview
Ask Author
Back to course home

0% completed

Solution: Find Original Array From Doubled Array
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Problem Statement

A doubled array changed is formed from the original array after appending twice the value of each element in the original array and randomly shuffling elements in the updated original array.

Given an array changed, return the original array if changed is a valid doubled array. Otherwise, return empty array.

Examples

  • Example 1:
    • Input: changed = [2,4,1,8]
    • Expected Output: [1,4]
    • Justification: The original array [1,4] is doubled to form [2,4,1,8] (1's double is 2, and 4's double is 8).

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible