HackerEarth Three problems solution - TheCScience