mediumHash TableSliding WindowString 0 views

Count Substrings With K-Frequency Characters I

Given a string s and an integer k, return the total number of substrings of s where at least one character appears at least k times.

Given a string s and an integer k, return the total number of substrings of s where at least one character appears at least k times.

Count Substrings With K-Frequency Characters I diagram

Example 1

Input: s = "abacb", k = 2

Output: 4

Explanation: The valid substrings are:

Example 2

Input: s = "abcde", k = 1

Output: 15

Explanation: All substrings are valid because every character appears at least once.

Constraints

  • 1 <= s.length <= 3000
  • 1 <= k <= s.length
  • s consists only of lowercase English letters.

Hints

Companies

No companies reported yet.

Discussion

Sign in to join the discussion.

Loading discussion...

Test results

No test cases yet.