solution :CodeChef | Competitive Programming | Participate & Learn question link: CodeChef | Competitive Programming | Participate & Learn