Nagarro Interview Question

Code optimization