2773. Height of Special Binary Tree
You are given a
root``nnodes. The nodes of the special binary tree are numbered from1ton. Suppose the tree haskleaves in the following order:b1 < b2 < ... < bk.
bi, the following conditions hold:
- The right child of
biisbi + 1ifi < k, andb1otherwise.- The left child of
biisbi - 1ifi > 1, andbkotherwise.Return the height of the given tree.
Note: The height of a binary tree is the length of the longest path from the root to any other node.
1 | /** |