Practice Maximum Sum of an Hourglass
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
An hourglass occupies seven cells within a 3 by 3 block: all three cells of its top row, only the center cell of its middle row, and all three cells of its bottom row. It cannot rotate or extend outside grid. Return the greatest sum of an hourglass in grid.
Source: Maximum Sum of an Hourglass on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
grid = [[6,2,1,3],[4,2,1,5],[9,2,8,7],[4,1,2,9]]
Output
30
# Example 2
Input
grid = [[1,2,3],[4,5,6],[7,8,9]]
Output
35
Constraints
m == grid.length
n == grid[i].length
3 <= m, n <= 150
0 <= grid[i][j] <= 10^6
Related LeetCode Problems
Practice more problems similar to Maximum Sum of an Hourglass.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.