Maximum Repeating Substring Leetcode Javascript Solution