Chewy interview question

Basic Data structure based problem