leetcode.cn 2026-08-12
🟡2958.length-of-longest-subarray-with-at-most-k-frequency
🏷️ Tags
#array #hash_table #sliding_window
🟡2958.length-of-longest-subarray-with-at-most-k-frequency
🏷️ Tags
#array #hash_table #sliding_window
Telegraph
length-of-longest-subarray-with-at-most-k-frequency
给你一个整数数组 nums 和一个整数 k 。 一个元素 x 在数组中的 频率 指的是它在数组中的出现次数。 如果一个数组中所有元素的频率都 小于等于 k ,那么我们称这个数组是 好 数组。 请你返回 nums 中 最长好 子数组的长度。 子数组 指的是一个数组中一段连续非空的元素序列。 示例 1: 输入:nums = [1,2,3,1,2,3,1,2], k = 2 输出:6 解释:最长好子数组是 [1,2,3,1,2,3] ,值 1 ,2 和 3 在子数组中的频率都没有超过 k = 2 。[2,3…
leetcode.com 2026-08-12
🟡2958.length-of-longest-subarray-with-at-most-k-frequency
🏷️ Tags
#array #hash_table #sliding_window
🟡2958.length-of-longest-subarray-with-at-most-k-frequency
🏷️ Tags
#array #hash_table #sliding_window
Telegraph
length-of-longest-subarray-with-at-most-k-frequency
You are given an integer array nums and an integer k. The frequency of an element x is the number of times it occurs in an array. An array is called good if the frequency of each element in this array is less than or equal to k. Return the length of the longest…
leetcode.cn 2026-08-13
🔴2213.longest-substring-of-one-repeating-character
🏷️ Tags
#segment_tree #array #string #ordered_set
🔴2213.longest-substring-of-one-repeating-character
🏷️ Tags
#segment_tree #array #string #ordered_set
Telegraph
longest-substring-of-one-repeating-character
给你一个下标从 0 开始的字符串 s 。另给你一个下标从 0 开始、长度为 k 的字符串 queryCharacters ,一个下标从 0 开始、长度也是 k 的整数 下标 数组 queryIndices ,这两个都用来描述 k 个查询。 第 i 个查询会将 s 中位于下标 queryIndices[i] 的字符更新为 queryCharacters[i] 。 返回一个长度为 k 的数组 lengths ,其中 lengths[i] 是在执行第 i 个查询 之后 s 中仅由 单个字符重复 组成的 最长子字符串…
leetcode.com 2026-08-13
🔴2213.longest-substring-of-one-repeating-character
🏷️ Tags
#segment_tree #array #string #ordered_set
🔴2213.longest-substring-of-one-repeating-character
🏷️ Tags
#segment_tree #array #string #ordered_set
Telegraph
longest-substring-of-one-repeating-character
You are given a 0-indexed string s. You are also given a 0-indexed string queryCharacters of length k and a 0-indexed array of integer indices queryIndices of length k, both of which are used to describe k queries. The ith query updates the character in s…
leetcode.cn 2026-08-14
🟢3090.maximum-length-substring-with-two-occurrences
🏷️ Tags
#hash_table #string #sliding_window
🟢3090.maximum-length-substring-with-two-occurrences
🏷️ Tags
#hash_table #string #sliding_window
Telegraph
maximum-length-substring-with-two-occurrences
给你一个字符串 s ,请找出满足每个字符最多出现两次的最长子字符串,并返回该子字符串的 最大 长度。 示例 1: 输入: s = "bcbbbcba" 输出: 4 解释: 以下子字符串长度为 4,并且每个字符最多出现两次:"bcbbbcba"。 示例 2: 输入: s = "aaaa" 输出: 2 解释: 以下子字符串长度为 2,并且每个字符最多出现两次:"aaaa"。 提示: