Longest Repeating Substring Leetcode Solution Python