Count Distinct Substrings Leetcode Playground Python