A damaged book contains a line of garbled text. A section is considered clear when every character in it is different.
Find the length of the longest consecutive clear section in the text. Characters cannot be skipped.
int longestClearSection(String garbledText)
garbledText: The text found in the damaged book.The length of the longest consecutive section containing no repeated characters.
0 ≤ garbledText.length() ≤ 100,000garbledText may contain letters, digits, spaces and special characters.garbledText is never null.0.longestClearSection(garbledText = "chaptermark")
Returns 8.
The section "chapterm" contains eight different characters.
longestClearSection(garbledText = "%%%%")
Returns 1.
Every character is the same, so a clear section can contain only one character.
longestClearSection(garbledText = "editorial")
Returns 6.
The sections "editor" and "torial" each contain six characters without repetition.