Dsa
Hashing
Medium
Common Elements in Three Arrays
You are given three arrays of integers. Your task is to find the common elements present in all three arrays. If there are no common elements, print 'No common elements'.
Input Format:
- The first line contains an integer n, the size of the first array.
- The second line contains n space-separated integers of the first array.
- The third line contains an integer m, the size of the second array.
- The fourth line contains m space-separated integers of the second array.
- The fifth line contains an integer k, the size of the third array.
- The sixth line contains k space-separated integers of the third array.
Output Format:
- Print the common elements in sorted order or 'No common elements' if there are none.
Example:
Input:
3
1 2 3
4
2 3 4 5
2
3 4
Output:
3
Key concepts
hashingintersectionarrays
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