class Solution:
def longestRepeatingSubstring(self, s: str) -> int:
n = len(s)
dp = [[0] * n for _ in range(n)]
max_length = 0
for i in range(n):
for j in range(i + 1, n):
if s[i] == s[j]:
dp[i][j] = dp[i - 1][j - 1] + 1 if i else 1
max_length = max(max_length, dp[i][j])
return max_length