Skip to content

Instantly share code, notes, and snippets.

View vishoo7's full-sized avatar

Vishal vishoo7

View GitHub Profile

Keybase proof

I hereby claim:

  • I am vishoo7 on github.
  • I am vishoe7 (https://keybase.io/vishoe7) on keybase.
  • I have a public key ASBpsYvpmVluIXQHG4z3Eqp6RpfnRT2Aa9s1L-efbAp3ugo

To claim this, I am signing this object:

@vishoo7
vishoo7 / RandomItemRetriever.py
Last active August 5, 2017 17:52
Interview question: implement a class that will take a list of lists and return the next item in a randomly selected list
from random import Random
class RandomItemRetriever:
'''
This class will take a list of lists and return the next item in a randomly selected list.
Time: O(1)
Space: O(n) where n = number of lists
'''
def __init__(self, lists):
# store original data (never mutated)
@vishoo7
vishoo7 / find_max_min.py
Last active April 10, 2017 01:47
Here's a recent interview problem. Find the walk from the top left to the bottom right that maximizes the minimum element traveled. I believe I have the brute force solution and the most efficient solution.
import sys
def find_max_min_brute(array, x=0, y=0):
max_x = max_y = len(array) - 1
current = array[y][x]
if x == max_x and y == max_y:
return current
if x == max_x:
return min(current, find_max_min_brute(array, x, y + 1))
if y == max_y: