100255. 成为 K 特殊字符串需要删除的最少字符数
题目
代码
class Solution {
// 方法接受一个字符串word和一个整数k,返回使word成为k特殊字符串需要删除的字符的最小数量
public int minimumDeletions(String word, int k) {
// cnts数组用于记录字符串中每个字符的出现次数
int[] cnts = new int[26];
for (char c : word.toCharArray()) {
cnts[c - 'a']++;
}
// list用于存储非零出现次数
List<Integer> list = new ArrayList<>();
for (int i = 0; i < 26; i++) {
if (cnts