Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. class Solution(object):
  2. def maxIncreaseKeepingSkyline(self, grid):
  3. """
  4. :type grid: List[List[int]]
  5. :rtype: int
  6. """
  7. colMax = [0] * len(grid[0])
  8. rowMax = []
  9.  
  10. for i in grid:
  11. rowMax.append(max(i))
  12. for jdx, j in enumerate(i):
  13. colMax[jdx] = j if j > colMax[jdx] else colMax[jdx]
  14.  
  15. print(rowMax, colMax)
  16.  
  17. sum = 0
  18. for idx, i in enumerate(grid):
  19. for jdx, j in enumerate(i):
  20. sum += min(colMax[jdx],rowMax[idx]) - j
  21. return sum
  22. '''
  23. Runtime: 52 ms, faster than 91.92% of Python online submissions for Max Increase to Keep City Skyline.
  24. Memory Usage: 11.8 MB, less than 50.00% of Python online submissions for Max Increase to Keep City Skyline.
  25. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement