#2730

Find the Longest Semi-Repetitive Substring

expert · 1050 · lc medium +32 · 38.6% accepted · 318 likes · top 18%

Description

Given a digit string s (digits 0–9), a substring is semi-repetitive if it contains at most one pair of adjacent identical digits. Return the length of the longest semi-repetitive substring of s.

Code

1
2
3