start and end to 0, and a variable max_length to 1 (since the minimum length of a semi-repetitive substring is 1).consecutive_pairs to 0 to keep track of consecutive pairs of the same digit within the current window.end pointer.
a. If the current character is the same as the previous one, increment consecutive_pairs.
b. While consecutive_pairs is greater than 1, move the start pointer to the right and decrement consecutive_pairs if we are breaking a consecutive pair.
c. Update max_length with the maximum of its current value and the length of the current window (end - start + 1).max_length as the result.