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:
Edge case returning zero.
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.