Nagarro Interview Question

programming question on Object modification and complexity reduction