Postgresql Count Distinct Substrings Leetcode Problems