From 26239f9a9735c66455522a2bd4ca022d12c86af1 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 27 Jul 2018 14:06:58 +0300 Subject: [PATCH] Refactor dynamic programming approach of Trapping Rain Water problem. --- src/algorithms/uncategorized/rain-terraces/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/uncategorized/rain-terraces/README.md b/src/algorithms/uncategorized/rain-terraces/README.md index d03548ef..5907ed6d 100644 --- a/src/algorithms/uncategorized/rain-terraces/README.md +++ b/src/algorithms/uncategorized/rain-terraces/README.md @@ -74,7 +74,7 @@ the sides minus its own height. - Initialize `answer = 0` - Iterate the array from left to right: - - Initialize `max_left = 0 and `max_right = 0` + - Initialize `max_left = 0` and `max_right = 0` - Iterate from the current element to the beginning of array updating: `max_left = max(max_left, height[j])` - Iterate from the current element to the end of array updating: `max_right = max(max_right, height[j])` - Add `min(max_left, max_right) − height[i]` to `answer`