Find the missing element between two arrays in Python
The challenge
Given two integer arrays where the second array is a shuffled duplicate of the first array with one element missing, find the missing element.
Please note, there may be duplicates in the arrays, so checking if a numerical value exists in one and not the other is not a valid solution.
|
|
|
|
The first array will always have at least one element.
Test cases
|
|
The solution in Python
Option 1 (using sum
):
Option 2 (using reduce
):
Option 3 (removing from list):