LeetCode Same Tree Problem Solved with BFS

🧠 Day 27 / 100 – DSA Practice Solved Same Tree problem on LeetCode 🌳✅ 🔹 Problem Insight: Check whether two binary trees are structurally identical and have the same node values. 🔹 Approach: Used Breadth-First Search (BFS) with a queue to traverse both trees simultaneously. Compared nodes at each step: ✔️ If both are null → continue ❌ If one is null or values differ → return false 🔹 Complexity: Time → O(n) Space → O(n) 💯 Result: ✔️ All test cases passed ⚡ Runtime: 0 ms (Beats 100%) Exploring trees step by step 🌲🚀 #Day27 #100DaysOfCode #LeetCode #Java #DSA #BinaryTree #BFS #CodingJourney #ProblemSolving

  • graphical user interface, text, application, chat or text message

To view or add a comment, sign in

Explore content categories