GlobalLogic interview question

Data structure