leetcode.com 2026-02-06
🟡3634.minimum-removals-to-balance-array
🏷️ Tags
#array #sorting #sliding_window
🟡3634.minimum-removals-to-balance-array
🏷️ Tags
#array #sorting #sliding_window
Telegraph
minimum-removals-to-balance-array
You are given an integer array nums and an integer k. An array is considered balanced if the value of its maximum element is at most k times the minimum element. You may remove any number of elements from nums without making it empty. Return the minimum…
leetcode.cn 2026-02-07
🟡1653.minimum-deletions-to-make-string-balanced
🏷️ Tags
#stack #string #dynamic_programming
🟡1653.minimum-deletions-to-make-string-balanced
🏷️ Tags
#stack #string #dynamic_programming
Telegraph
minimum-deletions-to-make-string-balanced
给你一个字符串 s ,它仅包含字符 'a' 和 'b' 。 你可以删除 s 中任意数目的字符,使得 s 平衡 。当不存在下标对 (i,j) 满足 i < j ,且 s[i] = 'b' 的同时 s[j]= 'a' ,此时认为 s 是 平衡 的。 请你返回使 s 平衡 的 最少 删除次数。 示例 1: 输入:s = "aababbab" 输出:2 解释:你可以选择以下任意一种方案: 下标从 0 开始,删除第 2 和第 6 个字符("aababbab" -> "aaabbb"), 下标从 0 开始,删除第…
leetcode.com 2026-02-07
🟡1653.minimum-deletions-to-make-string-balanced
🏷️ Tags
#stack #string #dynamic_programming
🟡1653.minimum-deletions-to-make-string-balanced
🏷️ Tags
#stack #string #dynamic_programming
Telegraph
minimum-deletions-to-make-string-balanced
You are given a string s consisting only of characters 'a' and 'b'. You can delete any number of characters in s to make s balanced. s is balanced if there is no pair of indices (i,j) such that i < j and s[i] = 'b' and s[j]= 'a'. Return the minimum number…
leetcode.cn 2026-02-09
🟡1382.balance-a-binary-search-tree
🏷️ Tags
#greedy #tree #depth_first_search #binary_search_tree #divide_and_conquer #binary_tree
🟡1382.balance-a-binary-search-tree
🏷️ Tags
#greedy #tree #depth_first_search #binary_search_tree #divide_and_conquer #binary_tree
Telegraph
balance-a-binary-search-tree
给你一棵二叉搜索树,请你返回一棵 平衡后 的二叉搜索树,新生成的树应该与原来的树有着相同的节点值。如果有多种构造方法,请你返回任意一种。 如果一棵二叉搜索树中,每个节点的两棵子树高度差不超过 1 ,我们就称这棵二叉搜索树是 平衡的 。 示例 1: 输入:root = [1,null,2,null,3,null,4,null,null] 输出:[2,1,3,null,null,null,4] 解释:这不是唯一的正确答案,[3,1,4,null,2,null,null] 也是一个可行的构造方案。 示例 2:…
leetcode.com 2026-02-09
🟡1382.balance-a-binary-search-tree
🏷️ Tags
#greedy #tree #depth_first_search #binary_search_tree #divide_and_conquer #binary_tree
🟡1382.balance-a-binary-search-tree
🏷️ Tags
#greedy #tree #depth_first_search #binary_search_tree #divide_and_conquer #binary_tree
Telegraph
balance-a-binary-search-tree
Given the root of a binary search tree, return a balanced binary search tree with the same node values. If there is more than one answer, return any of them. A binary search tree is balanced if the depth of the two subtrees of every node never differs by…
leetcode.cn 2026-02-10
🟡3719.longest-balanced-subarray-i
🏷️ Tags
#segment_tree #array #hash_table #divide_and_conquer #prefix_sum
🟡3719.longest-balanced-subarray-i
🏷️ Tags
#segment_tree #array #hash_table #divide_and_conquer #prefix_sum
Telegraph
longest-balanced-subarray-i
给你一个整数数组 nums。
leetcode.com 2026-02-10
🟡3719.longest-balanced-subarray-i
🏷️ Tags
#segment_tree #array #hash_table #divide_and_conquer #prefix_sum
🟡3719.longest-balanced-subarray-i
🏷️ Tags
#segment_tree #array #hash_table #divide_and_conquer #prefix_sum
Telegraph
longest-balanced-subarray-i
You are given an integer array nums. A subarray is called balanced if the number of distinct even numbers in the subarray is equal to the number of distinct odd numbers. Return the length of the longest balanced subarray. Example 1: Input: nums = [2,5,4…
leetcode.cn 2026-02-11
🔴3721.longest-balanced-subarray-ii
🏷️ Tags
#segment_tree #array #hash_table #divide_and_conquer #prefix_sum
🔴3721.longest-balanced-subarray-ii
🏷️ Tags
#segment_tree #array #hash_table #divide_and_conquer #prefix_sum
Telegraph
longest-balanced-subarray-ii
给你一个整数数组 nums。
leetcode.com 2026-02-11
🔴3721.longest-balanced-subarray-ii
🏷️ Tags
#segment_tree #array #hash_table #divide_and_conquer #prefix_sum
🔴3721.longest-balanced-subarray-ii
🏷️ Tags
#segment_tree #array #hash_table #divide_and_conquer #prefix_sum
Telegraph
longest-balanced-subarray-ii
You are given an integer array nums. A subarray is called balanced if the number of distinct even numbers in the subarray is equal to the number of distinct odd numbers. Return the length of the longest balanced subarray. Example 1: Input: nums = [2,5,4…
leetcode.cn 2026-02-12
🟡3713.longest-balanced-substring-i
🏷️ Tags
#hash_table #string #counting #enumeration
🟡3713.longest-balanced-substring-i
🏷️ Tags
#hash_table #string #counting #enumeration
Telegraph
longest-balanced-substring-i
给你一个由小写英文字母组成的字符串 s。
leetcode.com 2026-02-12
🟡3713.longest-balanced-substring-i
🏷️ Tags
#hash_table #string #counting #enumeration
🟡3713.longest-balanced-substring-i
🏷️ Tags
#hash_table #string #counting #enumeration
Telegraph
longest-balanced-substring-i
You are given a string s consisting of lowercase English letters. A substring of s is called balanced if all distinct characters in the substring appear the same number of times. Return the length of the longest balanced substring of s. Example 1: Input:…