Practice Count Submatrices with Top-Left Element and Sum Less Than k
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Medium#3070
LeetCode ProblemCount Submatrices with Top-Left Element and Sum Less Than k
Problem Statement
You are given a 0-indexed integer matrix grid and an integer k. Return the number of submatrices that contain the top-left element of the grid, and have a sum less than or equal to k.
Source: Count Submatrices with Top-Left Element and Sum Less Than k on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
grid = [[7,6,3],[6,6,1]], k = 18
Output
4
# Example 2
Input
grid = [[7,2,9],[1,5,0],[2,6,6]], k = 20
Output
6
Constraints
m == grid.length
n == grid[i].length
1 <= n, m <= 1000
0 <= grid[i][j] <= 1000
1 <= k <= 10^9
Related LeetCode Problems
Practice more problems similar to Count Submatrices with Top-Left Element and Sum Less Than k.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.