leetcode.cn 2025-08-20
🟡1277.count-square-submatrices-with-all-ones
🏷️ Tags
#array #dynamic_programming #matrix
🟡1277.count-square-submatrices-with-all-ones
🏷️ Tags
#array #dynamic_programming #matrix
Telegraph
count-square-submatrices-with-all-ones
给你一个 m * n 的矩阵,矩阵中的元素不是 0 就是 1,请你统计并返回其中完全由 1 组成的 正方形 子矩阵的个数。 示例 1: 输入:matrix = [ [0,1,1,1], [1,1,1,1], [0,1,1,1] ] 输出:15 解释: 边长为 1 的正方形有 10 个。 边长为 2 的正方形有 4 个。 边长为 3 的正方形有 1 个。 正方形的总数 = 10 + 4 + 1 = 15. 示例 2: 输入:matrix = [ [1,0,1], [1,1,0], [1,1…
leetcode.com 2025-08-20
🟡1277.count-square-submatrices-with-all-ones
🏷️ Tags
#array #dynamic_programming #matrix
🟡1277.count-square-submatrices-with-all-ones
🏷️ Tags
#array #dynamic_programming #matrix
Telegraph
count-square-submatrices-with-all-ones
Given a m * n matrix of ones and zeros, return how many square submatrices have all ones. Example 1: Input: matrix = [ [0,1,1,1], [1,1,1,1], [0,1,1,1] ] Output: 15 Explanation: There are 10 squares of side 1. There are 4 squares of side 2. There is…
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-08-23
🔴3197.find-the-minimum-area-to-cover-all-ones-ii
🏷️ Tags
#array #enumeration #matrix
🔴3197.find-the-minimum-area-to-cover-all-ones-ii
🏷️ Tags
#array #enumeration #matrix
Telegraph
find-the-minimum-area-to-cover-all-ones-ii
给你一个二维 二进制 数组 grid。你需要找到 3 个 不重叠、面积 非零 、边在水平方向和竖直方向上的矩形,并且满足 grid 中所有的 1 都在这些矩形的内部。 返回这些矩形面积之和的 最小 可能值。 注意,这些矩形可以相接。 示例 1: 输入: grid = [[1,0,1],[1,1,1]] 输出: 5 解释:
leetcode.com 2025-08-23
🔴3197.find-the-minimum-area-to-cover-all-ones-ii
🏷️ Tags
#array #enumeration #matrix
🔴3197.find-the-minimum-area-to-cover-all-ones-ii
🏷️ Tags
#array #enumeration #matrix
Telegraph
find-the-minimum-area-to-cover-all-ones-ii
You are given a 2D binary array grid. You need to find 3 non-overlapping rectangles having non-zero areas with horizontal and vertical sides such that all the 1's in grid lie inside these rectangles. Return the minimum possible sum of the area of these rectangles.…
leetcode.cn 2025-08-24
🟡1493.longest-subarray-of-1s-after-deleting-one-element
🏷️ Tags
#array #dynamic_programming #sliding_window
🟡1493.longest-subarray-of-1s-after-deleting-one-element
🏷️ Tags
#array #dynamic_programming #sliding_window
Telegraph
longest-subarray-of-1s-after-deleting-one-element
给你一个二进制数组 nums ,你需要从中删掉一个元素。 请你在删掉元素的结果数组中,返回最长的且只包含 1 的非空子数组的长度。 如果不存在这样的子数组,请返回 0 。 提示 1: 输入:nums = [1,1,0,1] 输出:3 解释:删掉位置 2 的数后,[1,1,1] 包含 3 个 1 。 示例 2: 输入:nums = [0,1,1,1,0,1,1,0,1] 输出:5 解释:删掉位置 4 的数字后,[0,1,1,1,1,1,0,1] 的最长全 1 子数组为 [1,1,1,1,1] 。 示例…
leetcode.com 2025-08-24
🟡1493.longest-subarray-of-1s-after-deleting-one-element
🏷️ Tags
#array #dynamic_programming #sliding_window
🟡1493.longest-subarray-of-1s-after-deleting-one-element
🏷️ Tags
#array #dynamic_programming #sliding_window
Telegraph
longest-subarray-of-1s-after-deleting-one-element
Given a binary array nums, you should delete one element from it. Return the size of the longest non-empty subarray containing only 1's in the resulting array. Return 0 if there is no such subarray. Example 1: Input: nums = [1,1,0,1] Output: 3 Explanation:…
leetcode.cn 2025-08-27
🔴3459.length-of-longest-v-shaped-diagonal-segment
🏷️ Tags
#memoization #array #dynamic_programming #matrix
🔴3459.length-of-longest-v-shaped-diagonal-segment
🏷️ Tags
#memoization #array #dynamic_programming #matrix
Telegraph
length-of-longest-v-shaped-diagonal-segment
给你一个大小为 n x m 的二维整数矩阵 grid,其中每个元素的值为 0、1 或 2。 V 形对角线段 定义如下:
leetcode.com 2025-08-27
🔴3459.length-of-longest-v-shaped-diagonal-segment
🏷️ Tags
#memoization #array #dynamic_programming #matrix
🔴3459.length-of-longest-v-shaped-diagonal-segment
🏷️ Tags
#memoization #array #dynamic_programming #matrix
Telegraph
length-of-longest-v-shaped-diagonal-segment
You are given a 2D integer matrix grid of size n x m, where each element is either 0, 1, or 2. A V-shaped diagonal segment is defined as: