You are on page 1of 8

THIS IS YOUR

PRESENTATION
TITLE
THANKS!
Any questions?
You can find me at
@username & user@mail.me

2
Trapping Of Rain Water

Team Members Prn No.

Prathamesh More 20200802214

Nikhil Gadge

1
Problem Satement

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.

Input: height = [4,2,0,3,2,5]


Output: 9
Trapped Water for a Block =

(water level - block Height)

4 2 0 3 2 5

Trapped Water = 0 + 2 + 4 + 1 + 2 + 0 =9
Base Case

Single Block of any height can't trap water

2 blocks of any height can't Trap Water

We need Block greater than or equal to trap water

so base case is n>2


4 2 0 3 2 5
NOTE

Amount of Trapped Water will depend on minimum boundary height

4 2 6 = 2 4 2 8 =2 6 2 8 =4

Height of water level = min(max left,max right)

You might also like