Dsa
Strings
Medium
Unique Substrings
Given a string s, write a program to find the number of unique substrings present in the string. A substring is a contiguous part of a string. Two substrings are considered different if they start or end at different indices. Print the count of unique substrings.
Example:
Input: ababc
Output: 8
Explanation: The unique substrings are: 'a', 'ab', 'aba', 'abab', 'b', 'ba', 'bab', 'c'.
Key concepts
stringssubstringscounting
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