Dsa
Trie
Easy
Distinct Substrings
Write a program to count the number of distinct substrings of a given string using a Trie data structure. You will read a string from input and output the count of distinct substrings.
Input format:
- A single line containing the string S (1 <= |S| <= 1000) consisting of lowercase letters only.
Output format:
- Output a single integer representing the number of distinct substrings of S.
Example:
Input:
abcab
Output:
10
Key concepts
triesubstringsstrings
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