Question bank › Hashing
Dsa Hashing Easy

Common Elements in Arrays

Given two lists of integers, find the common elements between them and output them in sorted order, without duplicates. Input: - The first line contains an integer n (1 ≤ n ≤ 1000), the size of the first list. - The second line contains n space-separated integers for the first list. - The third line contains an integer m (1 ≤ m ≤ 1000), the size of the second list. - The fourth line contains m space-separated integers for the second list. Output: - A space-separated list of common elements in sorted order. Example: Input: 5 1 2 3 4 5 4 3 4 5 6 Output: 3 4 5

Key concepts

hashingarrayssets

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.