HackerEarth Tree tearing problem solution - TheCScience