Solved Utopian Tree from HackerRank