-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
44d51b6
commit d2a0987
Showing
1 changed file
with
7 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Intuition for my code: | ||
|
||
Set two pointers l and r to the left and right end of height. | ||
Then we get the minimum height (minHeight) of these pointers since the level of the water cannot be higher than it. | ||
Then we move the two pointers towards the center. | ||
If the coming level is less than minHeight, then it will hold some water. | ||
Fill the water until we meet some "barrier" (with height larger than minHeight) and update l and r to repeat this process |
d2a0987
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have committed a code and Readme file in cpp. Please merge it.