We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
https://leetcode.com/problems/count-complete-tree-nodes/
往左找到最深的叶子节点,往右再找最深的叶子节点。
如果他们的深度一样,说明是棵完全二叉树,节点数套用公式2^n - 1。
否则再用同样的方法递归这个点的左子树和右子树。