Solved answer of Hacker rank and CodeChef. Feel free to submit any better or efficient code to help out the open source community.