Fundamentals
/
Longest Substring Without Two Contiguous Occurrences of Letter
⏸
00:00
↻
← Prev
Next →
▶
Question
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
Input
aabbaaaaabb
Output
aabbaa
Example 2:
Input
aabbaabbaabbaaa
Output
aabbaabbaabbaa
▶
Understand
▶
Approach
▶
My Code
▶
Reference Solution
Compare
8