Count Distinct Substrings Leetcode 1501