joe32140 / piccollage-intern-interview

Pairs, Trapped rainwater

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Questions

  1. Pairs:
given a list of N integers, 
count the number of pairs from this list whose difference is K. 
Input: 2 <= N <= 10^5 ; 0 < K < 10^9.
What is the time and space complexity of your approach?
  1. Trapped rainwater:
given a m x n matrix of positive integers representing an elevation map, 
compute the volume of water it is able to trap after raining.
Example: given [[1, 2, 5, 5], [2, 1, 4, 2], [5, 3, 2, 2]], you should return 1. 
Given [[98]], return 0. Given [[95, 2], [1, 17]]  return 0. 
Given [[3, 5, 5, 3], [5, 1, 3, 6], [3, 8, 8, 3]] return 6.

Usage

$ python pairs.py
$ python rainwater.py

About

Pairs, Trapped rainwater


Languages

Language:Python 100.0%