Nagarro interview question

Code optimization