Tech Mahindra interview question

Complete explanation on my framework