Skip to content

Practice Get Biggest Three Rhombus Sums in a Grid

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1878
LeetCode Problem

Get Biggest Three Rhombus Sums in a Grid

Problem Statement

For each rhombus wholly inside grid, sum the cells on its border. Its shape is a square rotated 45 degrees, with its corners on grid cells. A single cell is also a zero-area rhombus. Return the three largest distinct sums in descending order, or all distinct sums if fewer than three exist.

Source: Get Biggest Three Rhombus Sums in a Grid on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
grid = [[3,4,5,1,3],[3,3,4,2,3],[20,30,200,40,10],[1,5,5,4,1],[4,3,2,2,5]]
Output
[228,216,211]

# Example 2

Input
grid = [[1,2,3],[4,5,6],[7,8,9]]
Output
[20,9,8]

# Example 3

Input
grid = [[7,7,7]]
Output
[7]

Constraints

m == grid.length
n == grid[i].length
1 <= m, n <= 50
1 <= grid[i][j] <= 10^5

Related LeetCode Problems

Practice more problems similar to Get Biggest Three Rhombus Sums in a Grid.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.