please suggest efficient solution. asked 12 Oct, 21:30

I am assuming that you want to generate distinct substrings of a string. U could do this using trie in O(N^2) Just insert all suffix of the string in trie,and then count the number of nodes is trie.To get the strings u can do dfs. lets say abba Suffixabba,bba,ba,a Insert
a
Edit: Sorry i misread the question.If the substring can have only unique characters then u can do simple bruteforce as @ayushkapadia said. answered 23 Nov, 12:32

If you want to generate substrings which have only unique characters, then it is very simple done in O (N X 26). As the length of that substring will not be greater than 26 according to pegion hole principle. So just do the brute force that is for every i loop over all j greater than i, but stop whenever you see a repeated character.I am not considering printing time here.But in the worst case it will be O (26 X 26 X N).
answered 23 Nov, 18:00
