Ctrl K

Long Letter Streaks

Easy
A sensor writes a log log, a string of lowercase English letters. Equal letters standing next to each other form a streak: for example, "ttrooooe" consists of the streaks "tt", "r", "oooo" and "e". A streak is long if it has at least three letters. For every long streak, return the pair [start, end]: the indices of its first and last letter (0-based). List the pairs in the order the streaks appear in the string.
Example 1
log="kkkpqqqqzx" → [[0, 2], [4, 7]]

The streak kkk covers indices 0–2 and qqqq covers 4–7. The other letters stand alone.

Example 2
log="aabbaa" → []

Every streak has length 2, so there are no long ones and the answer is empty.

Example 3
log="mmm" → [[0, 2]]
Constraints
  • 1 ≤ len(log) ≤ 1000
  • log consists of lowercase English letters only
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsValue of a Roman Numeral EasyShared Start of Words EasyBracket Balance EasyWhere the Fragment Starts EasyLength of the Final Word Easy
loading Python…
Input
log="kkkpqqqqzx"
Expected
[[0, 2], [4, 7]]

Run checks the first 3 tests in your browser. Submit checks all 56 tests on the server, hidden ones included.