Fundamentals/Longest Substring Without Two Contiguous Occurrences of Letter
← PrevNext →
Given a string str containing only a and b, find the longest substring of str such that it does not contain more than two contiguous occurrences of a and b.
Example 1
Inputaabbaaaaabb
Outputaabbaa
Example 2:
Inputaabbaabbaabbaaa
Outputaabbaabbaabbaa