SHARE
TWEET

Untitled

a guest Aug 21st, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. '''
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top