IBM interview question

How can you optimize the above codes?