Unioning two arrays

Question

Given array A containing N elements and array B containing M elements, write a Python function that returns a union between arrays A and B. If array A and B have duplicate elements, you'll only need to add the duplicate element once.

For example:

[1, 2, 3, 4], [1, 3, 5, 7, 10] -> [1, 2, 3, 4, 5, 7, 10]
[1, 2, 3], [4, 5, 6] -> [1, 2, 3, 4, 5, 6]

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now