MEDIUMasked at 1 company

Check Completeness of a Binary Tree

A medium-tier problem at 58% community acceptance, tagged with Tree, Breadth-First Search, Binary Tree. Reported in interviews at Lyft and 0 others.

Founder's read

Lyft asks this medium-difficulty tree problem, and it catches candidates who overthink what 'complete' actually means. A binary tree is complete if all levels are fully filled except possibly the last, which must be filled left to right. You might assume a simple recursive traversal works, but the catch is efficiency: a naive approach wastes time on trees that are obviously incomplete. The acceptance rate sits around 58%, which signals that half the people walking in don't nail the optimal pattern on their first try. If this problem hits your live assessment and you blank on the trick, StealthCoder solves it in seconds, invisible to the proctor.

Companies asking
1
Difficulty
MEDIUM
Acceptance
58%

Companies that ask "Check Completeness of a Binary Tree"

If this hits your live OA

Check Completeness of a Binary Tree is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage.

Get StealthCoder
What this means

The naive approach counts total nodes and checks if the tree is a perfect binary tree of some height, but that's overkill and slow. The real insight: if a tree is complete, the leftmost path and rightmost path have a specific relationship. When leftmost depth equals rightmost depth, the tree is a perfect binary tree, so you can return true immediately. When they differ, the left subtree must be perfect and the right subtree must be complete. This cuts the problem from O(n) to O(log^2 n) in most cases. Candidates often miss this pattern and try level-order traversal with sentinel checks, which works but leaves performance on the table. The BFS approach is solid backup if the recursive pattern escapes you. StealthCoder hedges the moment you realize your first instinct wasn't optimal.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Check Completeness of a Binary Tree recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Check Completeness of a Binary Tree interview FAQ

Is 'complete' the same as 'perfect' in this problem?+

No. A perfect binary tree has every level completely filled. Complete is stricter in one way: every level must be full except the last, and the last must fill left to right. A perfect tree is always complete, but not vice versa. The problem tests whether you know the distinction.

Why does the naive O(n) solution get flagged?+

Counting all nodes and checking against 2^h-1 works functionally but treats the problem like a standard tree traversal. Lyft wants you to exploit the structural property of completeness to bail early. If left height equals right height, you're done. That's the optimization.

What's the trick to avoiding TLE on large trees?+

Track leftmost and rightmost depths without traversing the entire tree. Compare them recursively on left and right subtrees. A mismatch tells you whether to recurse left or right, cutting the search space fast. This pattern is the bridge between brute force and elegant.

Can I solve this with BFS and a queue?+

Yes. Do level-order traversal and check that once you hit a non-full node, all remaining nodes are leaves at the end. It's O(n) and works, but the recursive depth-comparison trick is faster. Use BFS if you're confident in your queue logic under pressure.

Does Lyft still ask this, or is it dated?+

Single company reported in recent data. That doesn't mean it's obsolete, but it's not a high-frequency ask across the industry. Medium trees are core to phone screens everywhere. If you see it, the pattern matters more than the company frequency.

Want the actual problem statement? View "Check Completeness of a Binary Tree" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.