Company: ZL Technologies
Difficulty: medium
Problem Title: Trapping Rainwater Problem Given an elevation map represented by n non-negative integers, where each integer corresponds to the height of a bar with a width of 1 unit, compute how much water the elevation map can trap after raining and the maximum amount of water trapped at any index in the elevation map. Solve it in optimal way with O(n) space. Input Format The first line contains an integer n - the number of bars in the elevation map. The second line contains n space-separated integers representing the heights of the bars. Output Format Print two integers: the total amount of water trapped and the maximum amount of water trapped at any index. Constraints 1 ≤ n ≤ 10 5 0 ≤ height[i] ≤ 10 4 Examples Input: 6 1 1 0 1 0 1 Output: 2 1 In this example, the total amount of water trapped is 2, and the maximum amount of water trapped at any index is 1. Input: 5 0 1 0 2 1 Output: 1 1 In this example, the total amount of water trapped is 1, and the maximum amount of water trapped