Z23
Trapping Rain Water
Problem Statement & Objective
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.
Function Signature (Python)
trapping_rain_water(heights: list[int]) -> intInput & Output Contract
Output Rule:Tutulan toplam su miktarı (tam sayı).
System Constraints
0 <= yukseklikler.length <= 2 * 10^5
0 <= yukseklikler[i] <= 10^5Example Execution Walkthrough
yukseklikler = [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1] -> tutulan su: 6 birimExample Test Scenarios (3)
Example 1
Input:
[[0,1,0,2,1,0,1,3,2,1,2,1]]Expected Output:
6Example 2
Input:
[[4,2,0,3,2,5]]Expected Output:
9Example 3: Su Tutulamaz
Input:
[[1,2,3]]Expected Output:
0