Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Trapped Rain Water algorithm. #714

Merged
merged 2 commits into from
Apr 16, 2024

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
4 of 5 checks passed
@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