Skip to content
CampusEduX

Find the Union of Two Arrays

Easyjavapythonccppjavascript

Given two arrays, create the set of every distinct value that appears in either array.

Input Format

The first line contains an integer N. The second line contains N space-separated integers (array A). The third line contains an integer M. The fourth line contains M space-separated integers (array B).

Output Format

Print the distinct values from either array in increasing order, separated by single spaces.

Related Problems

  • Find the Largest Element
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • Find the Smallest Element
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • Find the Second Largest Element
    Easy · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...