Practice Minimum Deletions to Make String K-Special
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Minimum Deletions to Make String K-Special
Problem Statement
You are given a string word and an integer k. We consider word to be k-special if |freq(word[i]) - freq(word[j])| <= k for all indices i and j in the string. Here, freq(x) denotes the frequency of the character x in word, and |y| denotes the absolute value of y. Return the minimum number of characters you need to delete to make word k-special.
Source: Minimum Deletions to Make String K-Special on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
word = "aabcaba", k = 0
3
# Example 2
word = "dabdcbdcdcd", k = 2
2
# Example 3
word = "aaabaaa", k = 2
1
Constraints
Related LeetCode Problems
Practice more problems similar to Minimum Deletions to Make String K-Special.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.