Generate All Substrings Leetcode 1501