UBS Interview Question

Solve a data structure problem and verify the code in github.