Different Logic to optimize this code further.

Printable View