text. Find the longest piece of it (consecutive characters) that occurs in the string at least twice, and return its length. The occurrences may overlap.
If no piece occurs twice, return 0.text="bananas" → 3
ana appears twice, starting at positions 1 and 3; occurrences may overlap. No piece of length 4 appears twice.
text="qwerty" → 0
All letters are different, so nothing repeats.
text="zzzz" → 3
zzz appears starting at position 0 and at position 1.
text) ≤ 2000text consists of lowercase English letterstext="bananas"
3
Run checks the first 3 tests in your browser. Submit checks all 102 tests on the server, hidden ones included.