Tech Mahindra interview question

Nothing much difficult