HackerEarth Doghouses problem solution - TheCScience