From b323162aa582dc26881c84c4915b4586e27953f9 Mon Sep 17 00:00:00 2001 From: Sandhya Mishra <102294639+Sandhyamishra18@users.noreply.github.com> Date: Tue, 18 Oct 2022 16:29:35 +0530 Subject: [PATCH] Rain Water Harvesting cpp solution Rain Water Harvesting cpp easy solution Name : Sandhya Mishra Github id : https://github.com/Sandhyamishra18 --- .../https:/github.com/Rain Water Harvesting | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 data_structures/C++/https:/github.com/Rain Water Harvesting diff --git a/data_structures/C++/https:/github.com/Rain Water Harvesting b/data_structures/C++/https:/github.com/Rain Water Harvesting new file mode 100644 index 0000000..a36f53f --- /dev/null +++ b/data_structures/C++/https:/github.com/Rain Water Harvesting @@ -0,0 +1,18 @@ +int solve(int n, vector height){ + vectorprefix(n),suffix(n); + int water = 0; + prefix[0] = height[0]; + suffix[n-1] = height[n-1]; + for(int i=1;i=0;i--){ + suffix[i] = max(suffix[i+1],height[i]); + } + for(int i=0;i