-
Notifications
You must be signed in to change notification settings - Fork 152
Description
Description
Implement the Trapping Rainwater Problem in C++.
Given an array representing the height of bars, calculate how much water can be trapped between them after it rains.
This is a classic array-based problem that helps in understanding prefix-suffix logic and the two-pointer approach.
Problem Statement
You are given an array height[] where each element represents the height of a bar.
The width of each bar is 1 unit.
Find the total amount of rainwater that can be trapped after raining.
Example
Input:
height[] = {4, 2, 0, 3, 2, 5}
Output:
9
Explanation:
Total trapped rainwater = 9 units
Expected Approach
Implement both brute-force and optimized (O(n)) solutions
Use two-pointer or prefix-suffix logic
Take user input dynamically
Display total trapped water clearly
hey @xthxr
If this issue is assigned, please label it under "hacktoberfest" tag....
Thank you.