Maximum Repeating Substring Leetcode Javascript Practice