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…
leetcode.cn 2025-06-27
🔴2014.longest-subsequence-repeated-k-times
🏷️ Tags
#greedy #string #backtracking #counting #enumeration
🔴2014.longest-subsequence-repeated-k-times
🏷️ Tags
#greedy #string #backtracking #counting #enumeration
Telegraph
longest-subsequence-repeated-k-times
给你一个长度为 n 的字符串 s ,和一个整数 k 。请你找出字符串 s 中 重复 k 次的 最长子序列 。 子序列 是由其他字符串删除某些(或不删除)字符派生而来的一个字符串。 如果 seq * k 是 s 的一个子序列,其中 seq * k 表示一个由 seq 串联 k 次构造的字符串,那么就称 seq 是字符串 s 中一个 重复 k 次 的子序列。
leetcode.com 2025-06-27
🔴2014.longest-subsequence-repeated-k-times
🏷️ Tags
#greedy #string #backtracking #counting #enumeration
🔴2014.longest-subsequence-repeated-k-times
🏷️ Tags
#greedy #string #backtracking #counting #enumeration
Telegraph
longest-subsequence-repeated-k-times
You are given a string s of length n, and an integer k. You are tasked to find the longest subsequence repeated k times in string s. A subsequence is a string that can be derived from another string by deleting some or no characters without changing the order…
leetcode.cn 2025-06-30
🟢594.longest-harmonious-subsequence
🏷️ Tags
#array #hash_table #counting #sorting #sliding_window
🟢594.longest-harmonious-subsequence
🏷️ Tags
#array #hash_table #counting #sorting #sliding_window
Telegraph
longest-harmonious-subsequence
和谐数组是指一个数组里元素的最大值和最小值之间的差别 正好是 1 。 给你一个整数数组 nums ,请你在所有可能的 子序列 中找到最长的和谐子序列的长度。 数组的 子序列 是一个由数组派生出来的序列,它可以通过删除一些元素或不删除元素、且不改变其余元素的顺序而得到。 示例 1: 输入:nums = [1,3,2,2,5,2,3,7] 输出:5 解释: 最长和谐子序列是 [3,2,2,2,3]。 示例 2: 输入:nums = [1,2,3,4] 输出:2 解释: 最长和谐子序列是 [1,2],[2…
leetcode.com 2025-06-30
🟢594.longest-harmonious-subsequence
🏷️ Tags
#array #hash_table #counting #sorting #sliding_window
🟢594.longest-harmonious-subsequence
🏷️ Tags
#array #hash_table #counting #sorting #sliding_window
Telegraph
longest-harmonious-subsequence
We define a harmonious array as an array where the difference between its maximum value and its minimum value is exactly 1. Given an integer array nums, return the length of its longest harmonious subsequence among all its possible subsequences. Example…
leetcode.com 2025-08-10
🟡869.reordered-power-of-2
🏷️ Tags
#hash_table #math #counting #enumeration #sorting
🟡869.reordered-power-of-2
🏷️ Tags
#hash_table #math #counting #enumeration #sorting
Telegraph
reordered-power-of-2
You are given an integer n. We reorder the digits in any order (including the original order) such that the leading digit is not zero. Return true if and only if we can do this so that the resulting number is a power of two. Example 1: Input: n = 1 Output:…
leetcode.cn 2025-09-13
🟢3541.find-most-frequent-vowel-and-consonant
🏷️ Tags
#hash_table #string #counting
🟢3541.find-most-frequent-vowel-and-consonant
🏷️ Tags
#hash_table #string #counting
Telegraph
find-most-frequent-vowel-and-consonant
给你一个由小写英文字母('a' 到 'z')组成的字符串 s。你的任务是找出出现频率 最高 的元音('a'、'e'、'i'、'o'、'u' 中的一个)和出现频率最高的辅音(除元音以外的所有字母),并返回这两个频率之和。 注意:如果有多个元音或辅音具有相同的最高频率,可以任选其中一个。如果字符串中没有元音或没有辅音,则其频率视为 0。
leetcode.com 2025-09-13
🟢3541.find-most-frequent-vowel-and-consonant
🏷️ Tags
#hash_table #string #counting
🟢3541.find-most-frequent-vowel-and-consonant
🏷️ Tags
#hash_table #string #counting
Telegraph
find-most-frequent-vowel-and-consonant
You are given a string s consisting of lowercase English letters ('a' to 'z'). Your task is to:
leetcode.cn 2025-09-22
🟢3005.count-elements-with-maximum-frequency
🏷️ Tags
#array #hash_table #counting
🟢3005.count-elements-with-maximum-frequency
🏷️ Tags
#array #hash_table #counting
Telegraph
count-elements-with-maximum-frequency
给你一个由 正整数 组成的数组 nums 。 返回数组 nums 中所有具有 最大 频率的元素的 总频率 。 元素的 频率 是指该元素在数组中出现的次数。 示例 1: 输入:nums = [1,2,2,3,1,4] 输出:4 解释:元素 1 和 2 的频率为 2 ,是数组中的最大频率。 因此具有最大频率的元素在数组中的数量是 4 。 示例 2: 输入:nums = [1,2,3,4,5] 输出:5 解释:数组中的所有元素的频率都为 1 ,是最大频率。 因此具有最大频率的元素在数组中的数量是 5 。 …
leetcode.com 2025-09-22
🟢3005.count-elements-with-maximum-frequency
🏷️ Tags
#array #hash_table #counting
🟢3005.count-elements-with-maximum-frequency
🏷️ Tags
#array #hash_table #counting
Telegraph
count-elements-with-maximum-frequency
You are given an array nums consisting of positive integers. Return the total frequencies of elements in nums such that those elements all have the maximum frequency. The frequency of an element is the number of occurrences of that element in the array. …