Dsa
Two Pointers
Easy
Common Elements in Two Sorted Arrays
Given two sorted arrays, find the common elements between them. The arrays may contain duplicates, but the output should contain each common element only once, sorted in ascending order. Read the two arrays from stdin and print the common elements. If there are no common elements, print an empty line.
Example:
Input:
1 2 3 4 5
2 3 5 6 7
Output:
2 3 5
Key concepts
two_pointersarrayssorting
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