Dsa
Two Pointers
Easy
Common Elements
Given two sorted arrays, your task is to find the number of elements that are common to both arrays. Print the count of these common elements.
Input Format:
- First line contains the integers of the first array separated by spaces.
- Second line contains the integers of the second array separated by spaces.
Output Format:
- A single integer representing the count of common elements.
Example:
Input:
1 2 3 4 5
2 3 5 6
Output:
3
Key concepts
two_pointersarrayssets
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