We just brute force our way into the matrix, do bound checks for our values and just calculate the required hour glass sum, and finally update our max sum with every iteration.
Code
Python
Big O Analysis
-
Runtime
The runtime complexity here is since we visit all elements atleast once.
-
Memory
The memory usage is since we are creating a new result array.
— A