MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / Solution

Class Solution

Array/max_increase_to_keep_city_skyline.py:32–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30"""
31
32class Solution(object):
33 def maxIncreaseKeepingSkyline(self, grid):
34 """
35 :type grid: List[List[int]]
36 :rtype: int
37 """
38 length = len(grid[0])
39
40 # Get line max.
41 line_dict = {str(index):max(data) for index, data in enumerate(grid)}
42 # Get column max.
43 column_dict = {str(index):max((grid[index2][index] for index2 in range(len(grid)))) for index in range(length)}
44
45 total_increases = 0
46
47 for index, line in enumerate(grid):
48 for index2, cell in enumerate(line):
49 total_increases += min([line_dict[str(index)], column_dict[str(index2)]]) - cell
50
51 return total_increases

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected