Skip to content

Conversation

@yaswanthkurri
Copy link

…Problem: Balanced Binary Tree
Check if a binary tree is height-balanced, meaning the heights of left and right subtrees of every node differ by at most 1.

Approach:

Bottom-up recursion to compute subtree heights.

Return -1 if any subtree is unbalanced.

Tree is balanced if final result is not -1.

Complexity:

Time: O(n)

Space: O(h) (recursion stack)

Tested on:

Empty tree, single node tree, balanced trees, and unbalanced trees.

@yaswanthkurri
Copy link
Author

Hi @maintainers,

Could you please take a look at this PR when you have a moment? Your review is needed to approve and merge it.

Thanks in advance! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant