3359. Find Sorted Submatrices With Maximum Element at Most K
You are given a 2D matrix
grid
of sizem x n
. You are also given a non-negative integerk
.Return the number of submatrices of
grid
that satisfy the following conditions:
- The maximum element in the submatrix less than or equal to
k
.- Each row in the submatrix is sorted in non-increasing order.
A submatrix
(x1, y1, x2, y2)
is a matrix that forms by choosing all cellsgrid[x][y]
wherex1 <= x <= x2
andy1 <= y <= y2
.
c++
1 | class Solution { |