-
807. Max Increase to Keep City SkylineAlgorithm/python tip 2021. 3. 2. 11:31
leetcode.com/problems/max-increase-to-keep-city-skyline/
class Solution(object): def maxIncreaseKeepingSkyline(self, grid): v_max = [] for i in range(0, len(grid)): v_max.append(max(grid[i])) s_max = [] for i in range(0, len(grid)): temp = -1 for j in range(0, len(grid)): if grid[j][i] > temp: temp = grid[j][i] s_max.append(temp) new_grid = [] for i in range(0, len(grid)): temp = [] for j in range(0, len(grid)): temp.append(min(v_max[i], s_max[j])) new_grid.append(temp) sum = 0 for i in range(0, len(grid)): for j in range(0, len(grid)): sum += new_grid[i][j] - grid[i][j] return sum
'Algorithm > python tip' 카테고리의 다른 글
1046. Last Stone Weight (0) 2021.03.02 [programmers] 스택/큐 - 기능개발 (0) 2021.03.02 1588. Sum of All Odd Length Subarrays (0) 2021.03.01 1732. Find the Highest Altitude (0) 2021.03.01 1679. Max Number of K-Sum Pairs (0) 2021.03.01