Generate All Substrings of a String
Problem Generate all contiguous substrings of a string — there are n(n+1)/2 of them.
Input / Output
- Input: a string
s. - Output: all contiguous substrings (clarify whether duplicates should be collapsed).
Constraints
- |s| ≤ ~100. The output is O(n^2) substrings totaling O(n^3) characters — state this before coding.
Example
"abc"→ a, ab, abc, b, bc, c.
asked …