Tap here to switch tabs
Problem
Submissions

Problem: Count Submatrices From Top-Left With Sum Less Than k

Try to solve the Count Submatrices with Top-Left Element and Sum Less Than k problem.

Statement

You are given a 00 indexed 2D2 {D} integer matrix grid and an integer k.

Return the number of submatrices containing the top left cell grid[0][0] such that the sum of their elements is less than or equal to k.

Constraints:

  • m == grid.length

  • n == grid[i].length

  • 1≤1 \leq m, n ≤1000\leq 1000

  • 0≤0 \leq grid[i][j] ≤1000\leq 1000

  • 1≤1 \leq k ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Submatrices From Top-Left With Sum Less Than k

Try to solve the Count Submatrices with Top-Left Element and Sum Less Than k problem.

Statement

You are given a 00 indexed 2D2 {D} integer matrix grid and an integer k.

Return the number of submatrices containing the top left cell grid[0][0] such that the sum of their elements is less than or equal to k.

Constraints:

  • m == grid.length

  • n == grid[i].length

  • 1≤1 \leq m, n ≤1000\leq 1000

  • 0≤0 \leq grid[i][j] ≤1000\leq 1000

  • 1≤1 \leq k ≤109\leq 10^9