๐๏ธ Max Increase to Keep City Skyline
Imagine you're a city planner working with a n ร n grid of buildings, where each cell represents the height of a building. Your goal is to maximize the total height increase of all buildings while preserving the city's iconic skyline from all four cardinal directions (north, south, east, west).
The skyline constraint means that when viewed from any direction, the tallest building in each row/column must remain the same. For example, if building at position (2,3) is the tallest in row 2, it must stay the tallest even after increases.
Key Challenge: Each building can be increased up to the minimum of:
- Maximum height in its row
- Maximum height in its column
Return the maximum total sum that all building heights can be increased by without changing any skyline view.
Input & Output
Constraints
- n == grid.length
- n == grid[i].length
- 1 โค n โค 50
- 0 โค grid[i][j] โค 100