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 | 678 Views, 18582 Search Bots | 85 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 678 Views, 18582 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 | 678 Views, 18582 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 Interview Question: Edit Distance
- Two-Sum
- Sort a Partially Sorted List
- Daily Interview Question: Word Search
- Daily Interview Problem: Circle of Chained Words
- Find the non-duplicate number
- Daily Interview Problem: Merge Overlapping Intervals
- Daily Interview Problem: Longest Substring With K Distinct Characters
- Daily Interview Problem: Largest Product of 3 Elements I
- Design Tic-Tac-Toe
©2006~2024 SteakOverCooked - 0.00894 Seconds(s) - 2062.968 KB/s - 25 Online Memory: 491.68 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 !