Description
Given a string s, find the length of the longest substring that appears at least twice in s. Overlapping occurrences are allowed.
Examples
Input:
s = "banana"Output:
3Explanation:
"ana" appears twice.
Input:
s = "abcd"Output:
0Explanation:
All characters are unique, so no substring appears more than once. The longest repeating substring has length 0.
Input:
s = "abcabc"Output:
3Explanation:
The substring "abc" appears twice in the string - once at the beginning and once at the end.
Constraints
- •
1 ≤ s.length ≤ 2000 - •
s consists of lowercase English letters.