# -*- coding: utf-8 -*-classSolution:"""
@param grid: a 2D array
@return: the maximum total sum that the height of the buildings can be increased
"""defmaxIncreaseKeepingSkyline(self, grid):# Write your code here
level_length =len(grid[0])
vertical_length =len(grid)
level_max =[0for i inrange(level_length)]
vertical_max =[0for i inrange(vertical_length)]for i inrange(level_length):for j inrange(vertical_length):if grid[i][j]> vertical_max[i]:
vertical_max[i]= grid[i][j]if grid[i][j]> level_max[j]:
level_max[j]= grid[i][j]
max_add =0for i inrange(level_length):for j inrange(vertical_length):whileTrue:if grid[i][j]< vertical_max[i]and grid[i][j]< level_max[j]:
max_add +=1
grid[i][j]+=1else:breakreturn max_add
# -*- coding: utf-8 -*-class Solution: """ @param grid: a 2D array @return: the maximum total sum that the height of the buildings can be increased """ def maxIncreaseKeepingSky...