Skip to content

Conversation

@sozelfist
Copy link
Contributor

Provides a function to calculate the amount of trapped rainwater between bars represented by an elevation map using dynamic programming.

Details:

  • The TrapRainWater function calculates the amount of trapped rainwater between the bars represented by the given elevation map.
  • It uses dynamic programming to precompute the maximum height of bars to the left and right of each position. Then, it iterates through the array to calculate the amount of trapped rainwater at each position based on the minimum of the left and right maximum heights.
  • Finally, it sums up the trapped rainwater for all positions and returns the total amount

@sozelfist
Copy link
Contributor Author

Let's take a look on this PR @raklaptudirm.

@raklaptudirm raklaptudirm merged commit e9d1f3c into TheAlgorithms:master Apr 16, 2024
@sozelfist sozelfist deleted the dp/trapped_rainwater branch April 17, 2024 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants