Question bank › Arrays
Dsa Arrays Easy

Common Elements In Sequences

Given two arrays of integers, find the common elements between them. The input format is as follows: Input: - The first line contains an integer n (1 <= n <= 1000) - the number of elements in the first array. - The second line contains n space-separated integers, the elements of the first array. - The third line contains an integer m (1 <= m <= 1000) - the number of elements in the second array. - The fourth line contains m space-separated integers, the elements of the second array. Output: - Print the common elements, sorted in ascending order, space-separated. Each element should appear only once in the output. Example: Input: 5 1 2 3 4 5 5 3 4 5 6 7 Output: 3 4 5

Key concepts

arraysintersectionsets

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.