Tech Mahindra interview question

Data structure, java