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 | 688 Views, 19038 Search Bots | 85 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 688 Views, 19038 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 | 688 Views, 19038 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
- [Daily Problem] Add two numbers as a linked list
- Daily Interview Problem: Maximum Profit From Stocks
- Daily Interview Question: Find Cycles in a Graph
- Skip the readings, focus on problems. And use all the hints!
- Algorithm Interview: Make the Largest Number
- Daily Interview Problem: Decode String
- New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
- Floor and Ceiling of a Binary Search Tree
- Daily Interview Problem: Count Number of Unival Subtrees
- Daily Interview Problem: Deepest Node in a Binary Tree
©2006~2024 SteakOverCooked - 0.00755 Seconds(s) - 2550.991 KB/s - 27 Online Memory: 493.65 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 !