Ctrl K

Triples Without Repeats

Easy
You are given a string text of lowercase English letters. Look at every run of exactly three consecutive characters in it: the one starting at the first letter, the one starting at the second, and so on. Count how many of these runs have three different letters. Equal runs at different positions are counted separately.
Example 1
text='banana' → 1

The three-letter windows are "ban", "ana", "nan" and "ana". Only "ban" has all different letters.

Example 2
text='planet' → 4

All four windows, "pla", "lan", "ane" and "net", have no repeats.

Example 3
text='ok' → 0

The string is shorter than three letters, so there are no windows.

Constraints
  • 1 ≤ text.length ≤ 100
  • text consists of lowercase English letters only
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsEvery Letter the Same Number of Times MediumA Single-Letter Piece Seen Three Times MediumA Single-Letter Piece Seen Three Times: Long Text MediumNote From Clipped Letters EasyFirst One-Off Letter Easy
loading Python…
Input
text='banana'
Expected
1

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