Common Elements Problem
Common Elements Problem — ExecCode School DSA Practice
Solve the Common Elements problem on ExecCode. Free online school DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.
Problem description
You are given two lists of numbers. Your task is to find any numbers that show up in BOTH lists. Print these common numbers, arranged from the smallest to the biggest.
Examples
Input 3 1 2 3 3 2 3 4; Output 2 3. Input 3 1 2 2 3 2 3 3; Output 2
Constraints
1 <= N, M <= 1000 -10^6 <= Array elements <= 10^6
Practice Common Elements free on ExecCode. Browse DSA problems, topic map, and placement guides.