8000 refine the comments · royeLin/leetcode_cpp@6f4d553 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6f4d553

Browse files
authored
refine the comments
1 parent a744f2b commit 6f4d553

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

algorithms/cpp/maximumBuildingHeight/MaximumBuildingHeight.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ So, we can figure out the following rules :
8686
- Building#1 max-height = 2, building#3 max-height = 5 : then, we only can make `[2,3,4]`
8787
- Building#1 max-height = 2, building#2 max-height = 9 : then, we only can make `[2,3]`
8888
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.
9090
9191
```
9292
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
112112
113113
we can process them couple by couple.
114114
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
118118
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
123124
124125
So, the correct answer of max height is `2`
125126

0 commit comments

Comments
 (0)
0