hackerrank utopian tree solution