Chewy Interview Question

Basic Data structure based problem