Chetan Dattachetan77.hashnode.dev·Oct 26, 2024Balanced Binary TreeProblem statement Given a binary tree, determine if it is height-balanced.(link) Example 1: Input: root = [3,9,20,null,null,15,7] Output: true Example 2: Input: root = [1,2,2,3,3,null,null,4,4] Output: false Example 3: Input: root = [] Output: tr...Leetcodebalanced-binary-tree
Vineeth Chivukulavineethchivukula.hashnode.dev·Jul 4, 2024Solving Binary Tree Level Order TraversalTo see the question, click here. Naive Approach The idea is to determine the tree's height and then, for each level from 1 to the tree's height, gather the nodes at that level and add them to the result list. // TC: O(nh) // SC: O(n) import java.uti...level-order
Kallol Bairagikallolbairagi.hashnode.dev·Oct 12, 2023#110.Balanced Binary Tree [LeetCode Grind 75 in Java]class Solution { public boolean ans = true; public int checkHeightDiff(TreeNode node){ if(node == null) return 0; int leftht = checkHeightDiff(node.left); int rightht = checkHeightDiff(node.right); if(Math.a...LeetCode Grind 75 in JavaDSA
Mehzabin Aothoimehzabin.hashnode.dev·Aug 13, 2023Binary Tree Vs Binary Search TreeWe know that a tree is a non-linear data structure that represents hierarchical data and contains no cycles. Now, let's delve into a commonly asked question during interviews: When do we call a tree a binary tree, and how does it differ from a binary...31 readsbinary tree
Haneunhanlee.hashnode.dev·Aug 4, 2023What is LCA(Lowest Common Ancestor)Definition Lowest Common Ancestor, LCA. LCA is an algorithm or concept used in tree structures to find the closest common ancestor of two nodes. Example In the above binary tree, the LCA of 4 and 6 is 1. LCA(4, 6) = 1 Purpose The purpose of the LCA...ProgrammingLowest Common Ancestor
Tanmay Sarkartanmaysarkar.hashnode.dev·Jun 24, 2023Binary Trees Explained: A Step-by-Step TutorialIntroduction 🧑🏽💻 Welcome to the fascinating world of binary trees! If you're new to this topic or looking to reinforce your understanding, you're in the right place. In this tutorial, I'll take you on a step-by-step journey through the fundamenta...114 readsWeMakeDevs