From d2a0987d21fbde2057c7978ec4f23222900e87df Mon Sep 17 00:00:00 2001 From: Sandhya-Rani05 <95161849+Sandhya-Rani05@users.noreply.github.com> Date: Tue, 3 Oct 2023 21:10:37 +0530 Subject: [PATCH] Create ReadmeForcpp.md --- LeetCode/Trapping-Rain-Water/ReadmeForcpp.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 LeetCode/Trapping-Rain-Water/ReadmeForcpp.md diff --git a/LeetCode/Trapping-Rain-Water/ReadmeForcpp.md b/LeetCode/Trapping-Rain-Water/ReadmeForcpp.md new file mode 100644 index 0000000..ad09857 --- /dev/null +++ b/LeetCode/Trapping-Rain-Water/ReadmeForcpp.md @@ -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