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 | 693 Views, 19967 Search Bots | 85 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 693 Views, 19967 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 | 693 Views, 19967 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] Longest Increasing Subsequence
- Daily Interview Problem: Given two arrays, write a function to compute their intersection.
- Staying on a Chess Board
- Daily Interview Problem: Product of Array Except Self
- Daily Interview Problem: Merge List Of Number Into Ranges
- First and Last Indices of an Element in a Sorted Array
- Sort a Partially Sorted List
- Algorithm Interview: Lowest Common Ancestor of 2 Nodes in Binary Tree
- Delphi Dynamic Array
- Daily Interview Problem: Jump to the End
©2006~2024 SteakOverCooked - 0.00668 Seconds(s) - 2931.003 KB/s - 8 Online Memory: 497.88 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 !