BETA

Difficulty Level: Medium

Submissions: 466 Accuracy:

4.29%

Count of distinct substrings (Function Problem)
       

Given a string of length n of lowercase alphabet characters, Your task is to complete the function countDistinctSubstring which returns the  count of total number of distinct substrings of this string.
Examples:

Input  : str = “ababa”
Output : 10
Total number of distinct substring are 10, which are,
"", "a", "b", "ab", "ba", "aba", "bab", "abab", "baba"
and "ababa"


Input:
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains a string str.

Output:
For each test case in a new line output will be an integer denoting count of total number of distinct substrings of this string.

Constraints:
1<=T<=50
1<=Length of string <=1000

Example(To be used only for expected output):
Input:

2
ab
ababa
Output:
4
10

 

** For More Input/Output Examples Use 'Expected Output' option **


					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.