Amazon Interview Question

First coding was function to produce weighted probability sampler given a list of weights, second was least common ancestor in binary tree