HackerEarth Rooms problem solution - TheCScience