Search⌘ K
AI Features

Solution: Find Longest Special Substring That Occurs Thrice I

C# solution for the Find Longest Special Substring That Occurs Thrice I problem using the Knowing What to Track pattern.

Statement

Given a string s, a substring is called special if it is made up of only one repeated character.

Return the maximum possible length of a special substring that appears in s at least three times. If no special substring occurs at least three times, return -1.

Note: Occurrences are counted by substring positions in s, and they may overlap.

Constraints:

  • 33 \leq s.length 50 ...