leetcode.cn 2025-11-10
🟡3542.minimum-operations-to-convert-all-elements-to-zero
🏷️ Tags
#stack #greedy #array #hash_table #monotonic_stack
🟡3542.minimum-operations-to-convert-all-elements-to-zero
🏷️ Tags
#stack #greedy #array #hash_table #monotonic_stack
Telegraph
minimum-operations-to-convert-all-elements-to-zero
给你一个大小为 n 的 非负 整数数组 nums 。你的任务是对该数组执行若干次(可能为 0 次)操作,使得 所有 元素都变为 0。 在一次操作中,你可以选择一个子数组 [i, j](其中 0 <= i <= j < n),将该子数组中所有 最小的非负整数 的设为 0。 返回使整个数组变为 0 所需的最少操作次数。
leetcode.com 2025-11-10
🟡3542.minimum-operations-to-convert-all-elements-to-zero
🏷️ Tags
#stack #greedy #array #hash_table #monotonic_stack
🟡3542.minimum-operations-to-convert-all-elements-to-zero
🏷️ Tags
#stack #greedy #array #hash_table #monotonic_stack
Telegraph
minimum-operations-to-convert-all-elements-to-zero
You are given an array nums of size n, consisting of non-negative integers. Your task is to apply some (possibly zero) operations on the array so that all elements become 0. In one operation, you can select a subarray [i, j] (where 0 <= i <= j < n) and set…
leetcode.cn 2026-01-11
🔴85.maximal-rectangle
🏷️ Tags
#stack #array #dynamic_programming #matrix #monotonic_stack
🔴85.maximal-rectangle
🏷️ Tags
#stack #array #dynamic_programming #matrix #monotonic_stack
Telegraph
maximal-rectangle
给定一个仅包含 0 和 1 、大小为 rows x cols 的二维二进制矩阵,找出只包含 1 的最大矩形,并返回其面积。 示例 1: 输入:matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]] 输出:6 解释:最大矩形如上图所示。 示例 2: 输入:matrix = [["0"]] 输出:0 示例 3: 输入:matrix = [["1"]] 输出:1 …
leetcode.com 2026-01-11
🔴85.maximal-rectangle
🏷️ Tags
#stack #array #dynamic_programming #matrix #monotonic_stack
🔴85.maximal-rectangle
🏷️ Tags
#stack #array #dynamic_programming #matrix #monotonic_stack
Telegraph
maximal-rectangle
Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. Example 1: Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]] Output: 6…
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…