func maxIncreaseKeepingSkyline(grid [][]int) int { m, n := len(grid), len(grid[0]) rArr := make([]int, n) cArr := make([]int, m) for i := 0; i < m; i++ { for j := 0; j < n; j++ { rArr[i] = max(rArr[i], grid[i][j]) cArr[j] = max(cArr[j], grid[i][j]) } } ans := 0 for i := 0; i < m; i++ { for j := 0; j < n; j++ { ans += max(grid[i][j], min(rArr[i], cArr[j])) - grid[i][j] } } return ans }