Jane Street Interview Question

data structure question using python