Dsa
Hashing
Easy
Common Substrings
Given two strings, find all substrings that are present in both strings. Print each common substring only once in alphabetical order.
Input format:
- The first line contains the first string.
- The second line contains the second string.
Output format:
- Print each common substring on a new line.
Example:
Input:
abcde
cdefg
Output:
cde
Key concepts
hashingsetssubstrings
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