Tap here to switch tabs
Problem
Submissions

Problem: Find Longest Special Substring That Occurs Thrice II

Find Longest Special Substring That Occurs Thrice II asks you to find the longest substring made of one repeated character that appears at least three times, or return -1 if none does.

Statement

You are given a string s that contains only lowercase English letters.

A substring of s is called special if it is composed of only a single distinct character.

Return the length of the longest special substring of s that appears at least 33 times, or −1-1 if no such substring exists.

Constraints:

  • 3≤3 \leq s.length ≤5×105\leq 5 \times 10^5

  • s consists of only lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Longest Special Substring That Occurs Thrice II

Find Longest Special Substring That Occurs Thrice II asks you to find the longest substring made of one repeated character that appears at least three times, or return -1 if none does.

Statement

You are given a string s that contains only lowercase English letters.

A substring of s is called special if it is composed of only a single distinct character.

Return the length of the longest special substring of s that appears at least 33 times, or −1-1 if no such substring exists.

Constraints:

  • 3≤3 \leq s.length ≤5×105\leq 5 \times 10^5

  • s consists of only lowercase English letters.