Solution Street interview question

Coding exercise was a simple data structure problem