Search
⌘K

Leetcode 222. Count Complete Tree Nodes

Given a complete binary tree, return its node count in less than O(n) time by exploiting the tree’s completeness (all full levels except a left-filled last level) to compute subtree heights and identify/count perfect subtrees without visiting every node.

Asked at:

Google

Google

Amazon

Amazon


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Late December, 2024

Google

Google

Mid-level

Count Nodes in a tree

Mid November, 2024

Amazon

Amazon

Junior

Complete Binary Tree Node Count: Find the total number of nodes in a given complete binary tree efficiently.

Comments

Your account is free and you can post anonymously if you choose.