Solution to Hacker Rank Challenges