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. …
leetcode.cn 2025-10-11
🟡3186.maximum-total-damage-with-spell-casting
🏷️ Tags
#array #hash_table #two_pointers #binary_search #dynamic_programming #counting #sorting
🟡3186.maximum-total-damage-with-spell-casting
🏷️ Tags
#array #hash_table #two_pointers #binary_search #dynamic_programming #counting #sorting
Telegraph
maximum-total-damage-with-spell-casting
一个魔法师有许多不同的咒语。 给你一个数组 power ,其中每个元素表示一个咒语的伤害值,可能会有多个咒语有相同的伤害值。 已知魔法师使用伤害值为 power[i] 的咒语时,他们就 不能 使用伤害为 power[i] - 2 ,power[i] - 1 ,power[i] + 1 或者 power[i] + 2 的咒语。 每个咒语最多只能被使用 一次 。 请你返回这个魔法师可以达到的伤害值之和的 最大值 。 示例 1: 输入:power = [1,1,3,4] 输出:6 解释: 可以使用咒语 0,1,3,伤害值分别为…
leetcode.com 2025-10-11
🟡3186.maximum-total-damage-with-spell-casting
🏷️ Tags
#array #hash_table #two_pointers #binary_search #dynamic_programming #counting #sorting
🟡3186.maximum-total-damage-with-spell-casting
🏷️ Tags
#array #hash_table #two_pointers #binary_search #dynamic_programming #counting #sorting
Telegraph
maximum-total-damage-with-spell-casting
A magician has various spells. You are given an array power, where each element represents the damage of a spell. Multiple spells can have the same damage value. It is a known fact that if a magician decides to cast a spell with a damage of power[i], they…
leetcode.cn 2025-10-24
🟡2048.next-greater-numerically-balanced-number
🏷️ Tags
#hash_table #math #backtracking #counting #enumeration
🟡2048.next-greater-numerically-balanced-number
🏷️ Tags
#hash_table #math #backtracking #counting #enumeration
Telegraph
next-greater-numerically-balanced-number
如果整数 x 满足:对于每个数位 d ,这个数位 恰好 在 x 中出现 d 次。那么整数 x 就是一个 数值平衡数 。 给你一个整数 n ,请你返回 严格大于 n 的 最小数值平衡数 。 示例 1: 输入:n = 1 输出:22 解释: 22 是一个数值平衡数,因为: - 数字 2 出现 2 次 这也是严格大于 1 的最小数值平衡数。 示例 2: 输入:n = 1000 输出:1333 解释: 1333 是一个数值平衡数,因为: - 数字 1 出现 1 次。 - 数字 3 出现 3 次。 这也是严格大于…
leetcode.com 2025-10-24
🟡2048.next-greater-numerically-balanced-number
🏷️ Tags
#hash_table #math #backtracking #counting #enumeration
🟡2048.next-greater-numerically-balanced-number
🏷️ Tags
#hash_table #math #backtracking #counting #enumeration
Telegraph
next-greater-numerically-balanced-number
An integer x is numerically balanced if for every digit d in the number x, there are exactly d occurrences of that digit in x. Given an integer n, return the smallest numerically balanced number strictly greater than n. Example 1: Input: n = 1 Output: 22…
leetcode.cn 2025-11-13
🟡3228.maximum-number-of-operations-to-move-ones-to-the-end
🏷️ Tags
#greedy #string #counting
🟡3228.maximum-number-of-operations-to-move-ones-to-the-end
🏷️ Tags
#greedy #string #counting
Telegraph
maximum-number-of-operations-to-move-ones-to-the-end
给你一个 二进制字符串 s。 你可以对这个字符串执行 任意次 下述操作:
leetcode.com 2025-11-13
🟡3228.maximum-number-of-operations-to-move-ones-to-the-end
🏷️ Tags
#greedy #string #counting
🟡3228.maximum-number-of-operations-to-move-ones-to-the-end
🏷️ Tags
#greedy #string #counting
Telegraph
maximum-number-of-operations-to-move-ones-to-the-end
You are given a binary string s. You can perform the following operation on the string any number of times: