Tap here to switch tabs
Problem
Submissions

Problem: Number Of Corner Rectangles

med
30 min
Try to solve the Number Of Corner Rectangles problem.

Statement

Given an mimesnm imes n integer matrix grid containing only 00’s and 11’s, return the total number of corner rectangles.

A corner rectangle consists of 44 distinct grid cells at coordinates (r1,c1)(r_1, c_1), (r1,c2)(r_1, c_2), (r2,c1)(r_2, c_1), and (r2,c2)(r_2, c_2) such that r1<r2r_1 < r_2, c1<c2c_1 < c_2, and all 44 corresponding cells in grid have a value of 11.

Constraints:

  • m == grid.length

  • n == grid[i].length

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

  • grid[i][j] is either 00 or 11.

  • The number of 11’s in grid is in the range [1,6000][1, 6000].

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number Of Corner Rectangles

med
30 min
Try to solve the Number Of Corner Rectangles problem.

Statement

Given an mimesnm imes n integer matrix grid containing only 00’s and 11’s, return the total number of corner rectangles.

A corner rectangle consists of 44 distinct grid cells at coordinates (r1,c1)(r_1, c_1), (r1,c2)(r_1, c_2), (r2,c1)(r_2, c_1), and (r2,c2)(r_2, c_2) such that r1<r2r_1 < r_2, c1<c2c_1 < c_2, and all 44 corresponding cells in grid have a value of 11.

Constraints:

  • m == grid.length

  • n == grid[i].length

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

  • grid[i][j] is either 00 or 11.

  • The number of 11’s in grid is in the range [1,6000][1, 6000].