Tap here to switch tabs
Problem
Submissions

Problem: Get Biggest Three Rhombus Sums in a Grid

Try to solve the Get Biggest Three Rhombus Sums in a Grid problem.

Statement

You are given an m×nm \times n matrix of integers grid.

A rhombus shape within grid has its border formed by connecting four corners: (r,c)(r, c), (r+k,c+k)(r + k, c + k), (r+2⋅k,c)(r + 2 \cdot k, c), and (r+k,c−k)(r + k, c - k) for some non negative integer k≥0k \ge 0. If k=0k = 0, the rhombus degenerates to a single cell located at (r,c)(r, c). All cells along the perimeter of the rhombus must strictly lie within the grid boundaries.

The rhombus sum is the sum of the elements residing on the border of the rhombus.

Return the 33 largest distinct rhombus sums in descending order. If there are fewer than 33 distinct rhombus sums, return all of them.

Constraints:

  • m ==== grid.length

  • n ==== grid[i].length

  • 1≤1 \le m, n ≤50\le 50

  • 1≤1 \le grid[i][j] ≤105\le 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Get Biggest Three Rhombus Sums in a Grid

Try to solve the Get Biggest Three Rhombus Sums in a Grid problem.

Statement

You are given an m×nm \times n matrix of integers grid.

A rhombus shape within grid has its border formed by connecting four corners: (r,c)(r, c), (r+k,c+k)(r + k, c + k), (r+2⋅k,c)(r + 2 \cdot k, c), and (r+k,c−k)(r + k, c - k) for some non negative integer k≥0k \ge 0. If k=0k = 0, the rhombus degenerates to a single cell located at (r,c)(r, c). All cells along the perimeter of the rhombus must strictly lie within the grid boundaries.

The rhombus sum is the sum of the elements residing on the border of the rhombus.

Return the 33 largest distinct rhombus sums in descending order. If there are fewer than 33 distinct rhombus sums, return all of them.

Constraints:

  • m ==== grid.length

  • n ==== grid[i].length

  • 1≤1 \le m, n ≤50\le 50

  • 1≤1 \le grid[i][j] ≤105\le 10^5