you give m x n integer matrix gridwe define hourglass matrix follow formreturn maximum sum element hourglassnote hourglass rotate entirely contain matrix example 1input grid 6213421592874129output 30explanation the cell show represent hourglass maximum sum 6 2 1 2 9 2 8 30example 2input grid 123456789output 35explanation there hourglass matrix sum 1 2 3 5 7 8 9 35 Constraintsm gridlengthn gridilength3 m n 1500 gridij 106