Solution to random problems on Hackerrank