From decc1734cadca69f4c73d330b69075426766805b Mon Sep 17 00:00:00 2001 From: Anant Singh <38243636+anantSinghCross@users.noreply.github.com> Date: Fri, 20 Aug 2021 12:27:45 +0530 Subject: [PATCH] Update RainWaterTrapped.cpp Updating the --i to ++i in the last loop. --- StacksAndQueues/RainWaterTrapped.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StacksAndQueues/RainWaterTrapped.cpp b/StacksAndQueues/RainWaterTrapped.cpp index bbf65dd..4fac275 100644 --- a/StacksAndQueues/RainWaterTrapped.cpp +++ b/StacksAndQueues/RainWaterTrapped.cpp @@ -26,7 +26,7 @@ int Solution::trap(const vector &arr) { right[n-1] = arr[n-1]; for (auto i = n-2; i >= 0; --i) right[i] = max(right[i+1], arr[i]); - for (auto i = 0; i < n; --i) + for (auto i = 0; i < n; ++i) water += min(left[i],right[i]) - arr[i]; return water; }