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