leetcode.cn 2025-06-21
🟡3085.minimum-deletions-to-make-string-k-special
🏷️ Tags
#greedy #hash_table #string #counting #sorting
🟡3085.minimum-deletions-to-make-string-k-special
🏷️ Tags
#greedy #hash_table #string #counting #sorting
Telegraph
minimum-deletions-to-make-string-k-special
给你一个字符串 word 和一个整数 k。 如果 |freq(word[i]) - freq(word[j])| <= k 对于字符串中所有下标 i 和 j 都成立,则认为 word 是 k 特殊字符串。 此处,freq(x) 表示字符 x 在 word 中的出现频率,而 |y| 表示 y 的绝对值。 返回使 word 成为 k 特殊字符串 需要删除的字符的最小数量。 示例 1: 输入:word = "aabcaba", k = 0 输出:3 解释:可以删除 2 个 "a" 和 1 个 "c" 使…
leetcode.com 2025-06-21
🟡3085.minimum-deletions-to-make-string-k-special
🏷️ Tags
#greedy #hash_table #string #counting #sorting
🟡3085.minimum-deletions-to-make-string-k-special
🏷️ Tags
#greedy #hash_table #string #counting #sorting
Telegraph
minimum-deletions-to-make-string-k-special
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…