← 返回 microsoft 的题目列表Longest Semi-Altered Substring
类型:online_judge
Given a string consisting only of characters 'a' and 'b', find the length of the longest semi-alterating substring. A semi-alterating substring is one that does not contain three consecutive identical characters.
Input
A string s containing only 'a' and 'b'.
Output
An integer representing the length of the longest semi-alterating substring.
Example 1
Input: "ababab"
Output: 6
Notes
Return 0 for an empty string input.
The input string will not exceed 100,000 characters.
Example
Input
"ababab"