Solutions to HackerRank problem