https://www.hackerrank.com/contests/nov13/challenges/utopian-tree