Solution to hackerRank problems