Z23

Trapping Rain Water

Staff / Principal Engineer
Target Time: 40 - 50 Minutes
Type: NUMERIC

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]) -> int

Input & Output Contract

Output Rule:Tutulan toplam su miktarı (tam sayı).

System Constraints

0 <= yukseklikler.length <= 2 * 10^5
0 <= yukseklikler[i] <= 10^5

Example Execution Walkthrough

yukseklikler = [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1] -> tutulan su: 6 birim

Example Test Scenarios (3)

Example 1
Input:[[0,1,0,2,1,0,1,3,2,1,2,1]]
Expected Output:6
Example 2
Input:[[4,2,0,3,2,5]]
Expected Output:9
Example 3: Su Tutulamaz
Input:[[1,2,3]]
Expected Output:0
Loading Python Editor...
Input Parameters
[
  [
    0,
    1,
    0,
    2,
    1,
    0,
    1,
    3,
    2,
    1,
    2,
    1
  ]
]
Expected Output
6