Tap here to switch tabs
Problem
Submissions

Problem: Minimum Deletions to Make String K-Special

med
30 min
Try to solve the Minimum Deletions to Make String K-Special problem.

Statement

You are given a string word and an integer k.

A string is considered kk special if the absolute difference between the frequencies of any two characters appearing in the string is at most kk. That is, ∣freq(c1)−freq(c2)∣≤k|freq(c_1) - freq(c_2)| \leq k for any two characters c1c_1 and c2c_2 present in the string, where freq(c)freq(c) represents the number of occurrences of character cc.

Return the minimum number of characters that must be deleted from word to make it kk special.

Constraints:

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

  • 0≤0 \leq k ≤105\leq 10^5

  • word consists only of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Deletions to Make String K-Special

med
30 min
Try to solve the Minimum Deletions to Make String K-Special problem.

Statement

You are given a string word and an integer k.

A string is considered kk special if the absolute difference between the frequencies of any two characters appearing in the string is at most kk. That is, ∣freq(c1)−freq(c2)∣≤k|freq(c_1) - freq(c_2)| \leq k for any two characters c1c_1 and c2c_2 present in the string, where freq(c)freq(c) represents the number of occurrences of character cc.

Return the minimum number of characters that must be deleted from word to make it kk special.

Constraints:

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

  • 0≤0 \leq k ≤105\leq 10^5

  • word consists only of lowercase English letters.