Solution to hackerearth problems