text. Find the longest substring (a contiguous piece of the string) in which no letter appears more than twice, and return its length.text='abacaba' → 5
The substring "bacab" (length 5) has two a's, two b's and one c. Nothing longer works: "abacab" already holds three a's.
text='zzzz' → 2
Any three letters in a row are three z's, so the answer is 2.
text='xyz' → 3
text consists only of lowercase English letterstext='abacaba'
5
Run checks the first 3 tests in your browser. Submit checks all 78 tests on the server, hidden ones included.