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 | 383 Views, 13928 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 | 383 Views, 13928 Search Bots | 85 Words Subscribe to Feed Burner

Related Articles

  1. Longest Substring Without Repeating Characters
  2. Design Tic-Tac-Toe
  3. Spreadsheet Column Title
  4. Daily Interview Problem: Room scheduling
  5. Daily Interview Problem: Get all Values at a Certain Height in a Binary Tree
  6. Daily Interview Problem: Sort Colors
  7. Spectrum Master
  8. Sorting a list with 3 unique numbers
  9. Find Missing Numbers in an Array
  10. [Daily Problem] Witness of The Tall People

Comments (0)

Your Email (Domain Part Not Exposed):

Your Comments:

Privately By Mail Colors More Smileys S x y @

Verification (Click Image 2 Refresh):

    Be the first one to comment this page !


Page Edited: October 30 2020 14:21:09 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />