File: root - text - article - 2019 - 11 - tapping-rainwater.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 679 Views, 18680 Search Bots | 85 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 679 Views, 18680 Search Bots | 85 Words
| Browse | Archive
Hi, here's your problem today. This problem was recently asked by Uber:
You have a landscape, in which puddles can form. You are given an array of non-negative integers representing the elevation at each location. Return the amount of water that would accumulate if it rains.
For example: [0,1,0,2,1,0,1,3,2,1,2,1] should return 6 because 6 units of water can get trapped here.
Here's your starting pont:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 679 Views, 18680 Search Bots | 85 Words You have a landscape, in which puddles can form. You are given an array of non-negative integers representing the elevation at each location. Return the amount of water that would accumulate if it rains.
For example: [0,1,0,2,1,0,1,3,2,1,2,1] should return 6 because 6 units of water can get trapped here.
X
X███XX█X
X█XX█XXXXXX
# [0,1,0,2,1,0,1,3,2,1,2,1]
Here's your starting pont:
def capacity(arr):
# Fill this in.
print capacity([0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1])
# 6
Related Articles
- Compare Version Numbers
- Find Pythagorean Triplets
- Daily Interview Problem: Group Words that are Anagrams
- Daily Interview Problem: Circle of Chained Words
- [Daily Problem] Move Zeros
- How to Play WAV music under DOS?
- Daily Interview Problem: Arithmetic Binary Tree
- Daily Interview Problem: Trapping Rainwater
- Daily Interview Problem: Buddy Strings
- Daily Interview Question: Find Cycles in a Graph
©2006~2024 SteakOverCooked - 0.01058 Seconds(s) - 1825.065 KB/s - 23 Online Memory: 491.35 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !