Tap here to switch tabs
Problem
Submissions

Problem: Count Complete Substrings

med
30 min
Try to solve the Count Complete Substrings problem.

Statement

You are given a string word and an integer k.

A substring of word is considered complete if it satisfies both of the following conditions:

  • Every distinct character present in the substring appears exactly k times within that substring.

  • The absolute difference between the alphabet positions of any two adjacent characters in the substring is at most 22.

Return the total number of complete substrings of word.

Constraints:

  • 1≤1 \leq word.length ≤105\leq 10^5

  • word consists only of lowercase English letters.

  • 1≤1 \leq k ≤\leq word.length

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Complete Substrings

med
30 min
Try to solve the Count Complete Substrings problem.

Statement

You are given a string word and an integer k.

A substring of word is considered complete if it satisfies both of the following conditions:

  • Every distinct character present in the substring appears exactly k times within that substring.

  • The absolute difference between the alphabet positions of any two adjacent characters in the substring is at most 22.

Return the total number of complete substrings of word.

Constraints:

  • 1≤1 \leq word.length ≤105\leq 10^5

  • word consists only of lowercase English letters.

  • 1≤1 \leq k ≤\leq word.length