@@ -86,7 +86,7 @@ So, we can figure out the following rules :
86
86
- Building#1 max-height = 2, building#3 max-height = 5 : then, we only can make `[2,3,4]`
87
87
- Building#1 max-height = 2, building#2 max-height = 9 : then, we only can make `[2,3]`
88
88
89
- So, we can have the following source code caluation the max height between two restractions.
89
+ So, we can have the following source code to calculate the max height between two restractions.
90
90
91
91
```
92
92
int getMaxHeight(vector<int>& left, vector<int>& right) {
@@ -112,14 +112,15 @@ BUT, we still have a case need to deal with, considering we have the following r
112
112
113
113
we can process them couple by couple.
114
114
115
- - `[1,1], [2,2]` : max-height = 2
116
- - `[2,2] ,[3,3]` : max-height = 3
117
- - `[3,3], [4,0]` : max-height = 1
115
+ - step 1: `[1,1], [2,2]` : max-height = 2
116
+ - step 2: `[2,2] ,[3,3]` : max-height = 3
117
+ - step 3: `[3,3], [4,0]` : max-height = 1
118
118
119
- for the last couple restractions, we can see the building#3 max-height is 1, so we have go backwards to recaluate the building#2 and building#1.
120
- - `[3,1], [4,0]` : max-height = 1
121
- - `[2,2] ,[3,1]` : max-height = 2
122
- - `[1,1], [2,2]` : max-height = 2
119
+ for the last couple of restractions, we can see the building#3 max-height is 1, so we have go backwards to recaluate the building#2 and building#1.
120
+
121
+ - step 3: `[3,1], [4,0]` : max-height = 1 (change the `[3,3]` to `[3,1]` )
122
+ - step:4: `[2,2] ,[3,1]` : max-height = 2
123
+ - step 5: `[1,1], [2,2]` : max-height = 2
123
124
124
125
So, the correct answer of max height is `2`
125
126
0 commit comments