leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
0807.cpp (585B)
0 class Solution { 1 public: 2 int maxIncreaseKeepingSkyline(const vector<vector<int>> &grid) { 3 int row[51] = {0}, col[51] = {0}; 4 int n = grid.size(); 5 6 for (int i = 0; i < n; i++) { 7 for (int j = 0; j < n; j++) { 8 row[i] = max(row[i], grid[i][j]); 9 col[j] = max(col[j], grid[i][j]); 10 } 11 } 12 13 int res = 0; 14 for (int i = 0; i < n; i++) { 15 for (int j = 0; j < n; j++) { 16 res += min(row[i], col[j]) - grid[i][j]; 17 } 18 } 19 20 return res; 21 } 22 };