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:…