I want to get all possible substrings of a string s excluding the duplicates.
eg: abba
Output:
a,ab,abb,abba,b,bb,bba,b,ba,a
Bold are repeated how to exclude it?
I know only C.
Thanks in advance
I want to get all possible substrings of a string s excluding the duplicates.
eg: abba
Output:
a,ab,abb,abba,b,bb,bba,b,ba,a
Bold are repeated how to exclude it?
I know only C.
Thanks in advance
You can get a substring’s hash in O(1) with some precalculations. Just iterate through all(O(N^2)) and store their hash code into a hash table. Every time you find a new code: print the substring or retain its position, whatever you like.
C implementation please! I mean without hash i am not concerned about complexity first want to learn the brute force algorithm!