Count Distinct Substrings Leetcode Problem