Answers to Hacker Rank questions