-
-
Save parcar/416d3f22b0c7f2e0df87d7736887e23f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution(object): | |
def maxIncreaseKeepingSkyline(self, grid): | |
""" | |
:type grid: List[List[int]] | |
:rtype: int | |
""" | |
colMax = [0] * len(grid[0]) | |
rowMax = [] | |
for i in grid: | |
rowMax.append(max(i)) | |
for jdx, j in enumerate(i): | |
colMax[jdx] = j if j > colMax[jdx] else colMax[jdx] | |
print(rowMax, colMax) | |
sum = 0 | |
for idx, i in enumerate(grid): | |
for jdx, j in enumerate(i): | |
sum += min(colMax[jdx],rowMax[idx]) - j | |
return sum | |
''' | |
Runtime: 52 ms, faster than 91.92% of Python online submissions for Max Increase to Keep City Skyline. | |
Memory Usage: 11.8 MB, less than 50.00% of Python online submissions for Max Increase to Keep City Skyline. | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment