To the Top
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 | 429 Views, 15349 Search Bots | 85 Words

Subscribe to Feed Burner | 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.

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
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 429 Views, 15349 Search Bots | 85 Words Subscribe to Feed Burner

Related Articles

  1. Daily Interview Problem: Queue Using Two Stacks
  2. Linode Support Ticket 10029540 - Other - Important Notice Regarding Ubuntu 17.10 Image
  3. Algorithm Interview: Determine If Linked List is Palindrome
  4. New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
  5. Algorithm Interview Question: Nth Fibonacci Number
  6. Algorithm Interview: Shifted String
  7. [Daily Problem] Angles of a Clock
  8. Daily Interview Question: Longest Sequence with Two Unique Numbers
  9. How to Play WAV music under DOS?
  10. Daily Interview Puzzle: Minimum Size Subarray Sum

Comments (0)

    Be the first one to comment this page !


Page Edited: May 11 2024 14:36:49 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="index, follow">