We get it, stuff happens. Just enter your email address below and we'll send you a link to reset your password!
Given a string, count all substrings of the given string.
First line contains string S.
Print the count of total substrings can form.
Login to see Discussion
Step-1: Find the length of string
Step-2: Calculate total substrings value is length of string * (length of string +1)/2
For every Stirng:
There will be n substring of length 1
there will be n-1 substring of length 2
there will be 1 substring of length n
Total substrings are 1+2+3+...+n = n(n+1)/2
Let us know if you can come up with a better approach, mail us at email@example.com Your approach will be reviewed and posted with credits to you.
Login to see Solution