Count Special Substrings in a DNA Sequence
You are given a DNA sequence string genome, consisting of lowercase Latin letters.
A substring of genome is considered special if it satisfies one of the following conditions:
Function Signature
def countSpecialSubstrings(genome: str) -> int:
Input
• A single string genome of length n where:
- 1 ≤ n ≤ 3 * 10^5
- genome contains only lowercase letters ('a' to 'z')
Output
• Return the total count of special substrings in the given genome string.
1Example 1
2Example 2
3Example 3
Constraints
Limits and guarantees your solution can rely on.
• 1 ≤ |genome| ≤ 300,000