Dsa
Hashing
Easy
Common Characters in Strings
Given two strings, return a list of characters that are common to both strings. Each character in the output should appear as many times as it is present in both strings.
Input Format:
Two lines where each line contains one string.
Output Format:
A single line of space-separated characters that are common in both strings, in the order of their appearance in the first string.
Example:
Input:
aabbcc
aabb
Output:
aa
Key concepts
hashingsetsintersection
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