文件: root - text - article - 2019 - 11 - tapping-rainwater.txt
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | 英文 | 主页 | 类别: 计算机科学 | 678 次阅读, 18589 次搜索 | 85 个单词
| 浏览 | 博客存档
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | 英文 | 主页 | 类别: 计算机科学 | 678 次阅读, 18589 次搜索 | 85 个单词
| 浏览 | 博客存档
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:
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | 英文 | 主页 | 类别: 计算机科学 | 678 次阅读, 18589 次搜索 | 85 个单词 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
猜您喜欢...
- Daily Interview Problem: Merge List Of Number Into Ranges
- Algorithm Interview: Lowest Common Ancestor of 2 Nodes in Binary Tree
- Most Frequent Subtree Sum
- Algorithm Interview: Longest Consecutive Sequence
- Palindrome Integers
- Find Pythagorean Triplets
- Daily Interview Problem: 3 Sum
- Daily Interview Problem: Reconstrunct Binary Tree from Preorder and Inorder Traversals
- Daily Interview Problem: Contiguous Subarray with Maximum Sum
- Daily Interview Problem: Get all Values at a Certain Height in a Binary Tree
©2006~2024 牛排过熟 - 0.00878 秒 - 2164.788 KB/s - 34 在线 内存: 492.45 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - 服务器 PHP 版本号: 7.4.33
牛排怎么做才好吃? | <meta name="机器人" content="不索引, 跟踪" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - 服务器 PHP 版本号: 7.4.33
评论 (0)
读写完全 - 一般 - 最小 - 表格 - 所有评论 - 统计
当前页暂时没有评论。