Skip to content
CampusEduX

Find the Intersection of Two Arrays

Easyjavapythonccppjavascript

Given two arrays, find the values that are present in both arrays. Each value must appear only once in the result.

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 common values in increasing order, separated by single spaces. If there are no common values, print an empty line.

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...