Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    3325 - Count Substrings With K-Frequency Characters I.

    Medium

    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.

    Example 1:

    Input: s = "abacb", k = 2

    Output: 4

    Explanation:

    The valid substrings are:

    • "aba" (character 'a' appears 2 times).

    • "abac" (character 'a' appears 2 times).

    • "abacb" (character 'a' appears 2 times).

    • "bacb" (character 'b' appears 2 times).

    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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Integer numberOfSubstrings(String s, Integer k)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait