Skip to content

dearshrewdwit/water_test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

You are given an input array whose each element represents the height of a line towers. The width of every tower is 1. It starts raining. How much water is collected between the towers?

Input: [1,5,3,7,2]
Output: 2 units

Explanation: 2 units of water collected between towers of height 5 and 7
Input: [5,3,7,2,6,4,5,9,1,2]
Output: 14 units

Explanation: 2 units of water collected between towers of height 5 and 7 +
             4 units of water collected between towers of height 7 and 6 +
             1 units of water collected between towers of height 6 and 5 +
             2 units of water collected between towers of height 6 and 9 +
             4 units of water collected between towers of height 7 and 9 +
             1 units of water collected between towers of height 9 and 2.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages