Tap here to switch tabs
Problem
Submissions

Problem: Find the Longest Semi-Repetitive Substring

Find the Longest Semi-Repetitive Substring asks you to examine a digit string and return the maximum length of a substring containing at most one adjacent pair of equal digits.

Statement

You are given a digit string s.

A string is called semi repetitive if there is at most one adjacent pair of identical digits within it.

Return the length of the longest semi repetitive substring found in s.

Constraints:

  • 1≤1 \leq s.length ≤50\leq 50

  • '0' ≤\leq s[i] ≤\leq '9'

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Longest Semi-Repetitive Substring

Find the Longest Semi-Repetitive Substring asks you to examine a digit string and return the maximum length of a substring containing at most one adjacent pair of equal digits.

Statement

You are given a digit string s.

A string is called semi repetitive if there is at most one adjacent pair of identical digits within it.

Return the length of the longest semi repetitive substring found in s.

Constraints:

  • 1≤1 \leq s.length ≤50\leq 50

  • '0' ≤\leq s[i] ≤\leq '9'