Sagitec Solutions interview question

code optimisation in java