Booj interview question

A whiteboard coding exercise