leetcode.cn 2025-06-19
🟡2294.partition-array-such-that-maximum-difference-is-k
🏷️ Tags
#greedy #array #sorting
🟡2294.partition-array-such-that-maximum-difference-is-k
🏷️ Tags
#greedy #array #sorting
Telegraph
partition-array-such-that-maximum-difference-is-k
给你一个整数数组 nums 和一个整数 k 。你可以将 nums 划分成一个或多个 子序列 ,使 nums 中的每个元素都 恰好 出现在一个子序列中。 在满足每个子序列中最大值和最小值之间的差值最多为 k 的前提下,返回需要划分的 最少 子序列数目。 子序列 本质是一个序列,可以通过删除另一个序列中的某些元素(或者不删除)但不改变剩下元素的顺序得到。 示例 1: 输入:nums = [3,6,1,2,5], k = 2 输出:2 解释: 可以将 nums 划分为两个子序列 [3,1,2] 和 [6,5]…
leetcode.com 2025-06-19
🟡2294.partition-array-such-that-maximum-difference-is-k
🏷️ Tags
#greedy #array #sorting
🟡2294.partition-array-such-that-maximum-difference-is-k
🏷️ Tags
#greedy #array #sorting
Telegraph
partition-array-such-that-maximum-difference-is-k
You are given an integer array nums and an integer k. You may partition nums into one or more subsequences such that each element in nums appears in exactly one of the subsequences. Return the minimum number of subsequences needed such that the difference…
leetcode.cn 2025-06-20
🟡3443.maximum-manhattan-distance-after-k-changes
🏷️ Tags
#hash_table #math #string #counting
🟡3443.maximum-manhattan-distance-after-k-changes
🏷️ Tags
#hash_table #math #string #counting
Telegraph
maximum-manhattan-distance-after-k-changes
给你一个由字符 'N'、'S'、'E' 和 'W' 组成的字符串 s,其中 s[i] 表示在无限网格中的移动操作:
leetcode.com 2025-06-20
🟡3443.maximum-manhattan-distance-after-k-changes
🏷️ Tags
#hash_table #math #string #counting
🟡3443.maximum-manhattan-distance-after-k-changes
🏷️ Tags
#hash_table #math #string #counting
Telegraph
maximum-manhattan-distance-after-k-changes
You are given a string s consisting of the characters 'N', 'S', 'E', and 'W', where s[i] indicates movements in an infinite grid:
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-26
🟡2311.longest-binary-subsequence-less-than-or-equal-to-k
🏷️ Tags
#greedy #memoization #string #dynamic_programming
🟡2311.longest-binary-subsequence-less-than-or-equal-to-k
🏷️ Tags
#greedy #memoization #string #dynamic_programming
Telegraph
longest-binary-subsequence-less-than-or-equal-to-k
给你一个二进制字符串 s 和一个正整数 k 。 请你返回 s 的 最长 子序列的长度,且该子序列对应的 二进制 数字小于等于 k 。 注意:
leetcode.com 2025-06-26
🟡2311.longest-binary-subsequence-less-than-or-equal-to-k
🏷️ Tags
#greedy #memoization #string #dynamic_programming
🟡2311.longest-binary-subsequence-less-than-or-equal-to-k
🏷️ Tags
#greedy #memoization #string #dynamic_programming
Telegraph
longest-binary-subsequence-less-than-or-equal-to-k
You are given a binary string s and a positive integer k. Return the length of the longest subsequence of s that makes up a binary number less than or equal to k. Note:
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-28
🟢2099.find-subsequence-of-length-k-with-the-largest-sum
🏷️ Tags
#array #hash_table #sorting #heap_priority_queue
🟢2099.find-subsequence-of-length-k-with-the-largest-sum
🏷️ Tags
#array #hash_table #sorting #heap_priority_queue
Telegraph
find-subsequence-of-length-k-with-the-largest-sum
给你一个整数数组 nums 和一个整数 k 。你需要找到 nums 中长度为 k 的 子序列 ,且这个子序列的 和最大 。 请你返回 任意 一个长度为 k 的整数子序列。 子序列 定义为从一个数组里删除一些元素后,不改变剩下元素的顺序得到的数组。 示例 1: 输入:nums = [2,1,3,3], k = 2 输出:[3,3] 解释: 子序列有最大和:3 + 3 = 6 。 示例 2: 输入:nums = [-1,-2,3,4], k = 3 输出:[-1,3,4] 解释: 子序列有最大和:-1 +…
leetcode.com 2025-06-28
🟢2099.find-subsequence-of-length-k-with-the-largest-sum
🏷️ Tags
#array #hash_table #sorting #heap_priority_queue
🟢2099.find-subsequence-of-length-k-with-the-largest-sum
🏷️ Tags
#array #hash_table #sorting #heap_priority_queue
Telegraph
find-subsequence-of-length-k-with-the-largest-sum
You are given an integer array nums and an integer k. You want to find a subsequence of nums of length k that has the largest sum. Return any such subsequence as an integer array of length k. A subsequence is an array that can be derived from another array…
leetcode.cn 2025-06-29
🟡1498.number-of-subsequences-that-satisfy-the-given-sum-condition
🏷️ Tags
#array #two_pointers #binary_search #sorting
🟡1498.number-of-subsequences-that-satisfy-the-given-sum-condition
🏷️ Tags
#array #two_pointers #binary_search #sorting
Telegraph
number-of-subsequences-that-satisfy-the-given-sum-condition
给你一个整数数组 nums 和一个整数 target 。 请你统计并返回 nums 中能满足其最小元素与最大元素的 和 小于或等于 target 的 非空 子序列的数目。 由于答案可能很大,请将结果对 109 + 7 取余后返回。 示例 1: 输入:nums = [3,5,6,7], target = 9 输出:4 解释:有 4 个子序列满足该条件。 [3] -> 最小元素 + 最大元素 <= target (3 + 3 <= 9) [3,5] -> (3 + 5 <= 9) [3,5,6] -> (3…