leetcode.com 2024-01-20
🟡907.sum-of-subarray-minimums
🏷️ Tags
#stack #array #dynamic_programming #monotonic_stack
🟡907.sum-of-subarray-minimums
🏷️ Tags
#stack #array #dynamic_programming #monotonic_stack
Telegraph
sum-of-subarray-minimums
Given an array of integers arr, find the sum of min(b), where b ranges over every (contiguous) subarray of arr. Since the answer may be large, return the answer modulo 109 + 7. Example 1: Input: arr = [3,1,2,4] Output: 17 Explanation: Subarrays are [3]…
leetcode.com 2025-03-29
🔴2818.apply-operations-to-maximize-score
🏷️ Tags
#stack #greedy #array #math #number_theory #sorting #monotonic_stack
🔴2818.apply-operations-to-maximize-score
🏷️ Tags
#stack #greedy #array #math #number_theory #sorting #monotonic_stack
Telegraph
apply-operations-to-maximize-score
You are given an array nums of n positive integers and an integer k. Initially, you start with a score of 1. You have to maximize your score by applying the following operation at most k times:
leetcode.cn 2025-08-21
🟡1504.count-submatrices-with-all-ones
🏷️ Tags
#stack #array #dynamic_programming #matrix #monotonic_stack
🟡1504.count-submatrices-with-all-ones
🏷️ Tags
#stack #array #dynamic_programming #matrix #monotonic_stack
Telegraph
count-submatrices-with-all-ones
给你一个 m x n 的二进制矩阵 mat ,请你返回有多少个 子矩形 的元素全部都是 1 。 示例 1: 输入:mat = [[1,0,1],[1,1,0],[1,1,0]] 输出:13 解释:有 6 个 1x1 的矩形。 有 2 个 1x2 的矩形。 有 3 个 2x1 的矩形。 有 1 个 2x2 的矩形。 有 1 个 3x1 的矩形。 矩形数目总共 = 6 + 2 + 3 + 1 + 1 = 13 。 示例 2: 输入:mat = [[0,1,1,0],[0,1,1,1],[1,1,1,0]]…
leetcode.com 2025-08-21
🟡1504.count-submatrices-with-all-ones
🏷️ Tags
#stack #array #dynamic_programming #matrix #monotonic_stack
🟡1504.count-submatrices-with-all-ones
🏷️ Tags
#stack #array #dynamic_programming #matrix #monotonic_stack
Telegraph
count-submatrices-with-all-ones
Given an m x n binary matrix mat, return the number of submatrices that have all ones. Example 1: Input: mat = [[1,0,1],[1,1,0],[1,1,0]] Output: 13 Explanation: There are 6 rectangles of side 1x1. There are 2 rectangles of side 1x2. There are 3 rectangles…
leetcode.cn 2025-10-30
🔴1526.minimum-number-of-increments-on-subarrays-to-form-a-target-array
🏷️ Tags
#stack #greedy #array #dynamic_programming #monotonic_stack
🔴1526.minimum-number-of-increments-on-subarrays-to-form-a-target-array
🏷️ Tags
#stack #greedy #array #dynamic_programming #monotonic_stack
Telegraph
minimum-number-of-increments-on-subarrays-to-form-a-target-array
给你一个整数数组 target 和一个数组 initial ,initial 数组与 target 数组有同样的维度,且一开始全部为 0 。 请你返回从 initial 得到 target 的最少操作次数,每次操作需遵循以下规则:
leetcode.com 2025-10-30
🔴1526.minimum-number-of-increments-on-subarrays-to-form-a-target-array
🏷️ Tags
#stack #greedy #array #dynamic_programming #monotonic_stack
🔴1526.minimum-number-of-increments-on-subarrays-to-form-a-target-array
🏷️ Tags
#stack #greedy #array #dynamic_programming #monotonic_stack
Telegraph
minimum-number-of-increments-on-subarrays-to-form-a-target-array
You are given an integer array target. You have an integer array initial of the same size as target with all elements initially zeros. In one operation you can choose any subarray from initial and increment each value by one. Return the minimum number of…
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…