Skip to content

pollycarp/leetcode-binary-tree-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Binary Tree Solutions – Java

This repository contains four classic binary tree algorithms implemented in Java. Each problem includes a reusable TreeNode class, a well-commented solution, and a main() test harness with sample cases.

πŸ“‚ Problems Covered

  1. βœ… Same Tree

    • Check if two binary trees are structurally identical and have the same values.
  2. βœ… Symmetric Tree

    • Check whether a binary tree is a mirror of itself (i.e., symmetric around its center).
  3. βœ… Balanced Binary Tree

    • Determine if a binary tree is height-balanced.
  4. βœ… Invert Binary Tree

    • Invert a binary tree by swapping left and right children recursively.

πŸ§ͺ How to Run

Compile and run the program using any Java IDE or CLI.

javac BinaryTreeSolutions.java
java BinaryTreeSolutions

πŸ“Ž Sample Output

Same Tree: true
Symmetric Tree: true
Balanced Tree: true
Before invert (root.left.val): 2
After invert (root.left.val): 3

πŸ‘¨β€πŸ’» Author Contact

Feel free to reach out for questions, collaborations, or feedback!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages