CTCI solution to array to bin tree problem.