word of lowercase English letters. You may swap any two of its letters, at most once.
Return the greatest possible length of a stretch of the string made of a single repeated letter.word="ccdcc" → 4
Swap the d with the last c to get ccccd, with four c in a row. There is no fifth c to fill the gap.
word="xyzzyx" → 2
The best you can get is two equal letters in a row, such as the zz already there.
word="mmnmmnm" → 5
Swap the first n with the last m: mmmmmnn has five m in a row.
word) ≤ 2·10⁴word consists of lowercase English lettersword="ccdcc"
4
Run checks the first 3 tests in your browser. Submit checks all 59 tests on the server, hidden ones included.