We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 659c17f commit 8155611Copy full SHA for 8155611
807.cpp
@@ -0,0 +1,45 @@
1
+class Solution {
2
+public:
3
+ int maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {
4
+ int x=grid.size();
5
+ int y=grid[0].size();
6
+ int A[x][y];
7
+ for(int i=0;i<x;i++){
8
+ for(int j=0;j<y;j++){
9
+ A[i][j]=grid[i][j];
10
+ }
11
12
+ int B[y];
13
14
+ int max1=INT_MIN;
15
16
+ if(A[i][j] > max1){
17
+ max1=A[i][j];
18
19
+ B[j]=max1;
20
21
22
+ int C[x];
23
+ for(int j=0;j<x;j++){
24
+ int max2=INT_MIN;
25
+ for(int i=0;i<y;i++){
26
+ if(A[j][i] > max2){
27
+ max2=A[j][i];
28
29
+ C[j]=max2;
30
31
32
33
34
+ A[i][j]=min(B[j],C[i]);
35
36
37
+ long long int sum=0;
38
39
40
+ sum=sum+( A[i][j] - grid[i][j] );
41
42
43
+ return sum;
44
45
+};
0 commit comments