Solved unique binary search tree problem