Axoni interview question

Typical coding puzzle about data structures. Had to code on google docs.