## Count Good Nodes in Binary Tree Leetcode Solution

Problem Statement   In this problem a binary tree is given with its root. A node X in the tree is named good if in the path from root to X there are no nodes with a value greater than X. We have to return the number of good nodes in …

## Maximum Depth of Binary Tree Leetcode Solution

Problem Statement   In the problem a binary tree is given and we have to find out the maximum depth of the given tree. A binary tree’s maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Example 3 / …

## Iterative Inorder Traversal of a Binary Tree

In “Iterative Inorder Traversal of a Binary Tree” problem we are given a binary tree. We need to traverse it in inorder fashion “iteratively”, without the recursion. Example   2 / \ 1 3 / \ 4 5 4 1 5 2 3 1 / \ 2 3 / \ 4 …

## Minimum Depth of Binary Tree Leetcode Solution

In this problem, we need to find the length of the shortest path from the root to any leaf in a given binary tree. Note that the “length of the path” here means the number of nodes from the root node to the leaf node. This length is called Minimum …

## Kth ancestor of a node in binary tree

Problem Statement   The problem “Kth ancestor of a node in binary tree” states that you are given a binary tree and a node. Now we need to find the kth ancestor of this node. An ancestor of any node is the nodes that lie on the path from the root …

## Construct Binary Tree from given Parent Array representation

The problem “Construct Binary Tree from given Parent Array representation” states that you are given an array. This input array represents a binary tree. Now you need to construct a binary tree on the basis of this input array. The array stores the index of parent node at each index. …

## Find distance between two nodes of a Binary Tree

Problem Statement   The problem “Find distance between two nodes of a Binary Tree” states that you are given a binary tree and you are given two nodes. Now you need to find the minimum distance between these two nodes. Example   // Tree is shown using the image above node 1 …

## Write Code to Determine if Two Trees are Identical

The problem “Write Code to Determine if Two Trees are Identical” states that you are given two binary trees. find out if they are identical or not? Here, identical tree means that both the binary trees have the same node value with the same arrangement of nodes. Example   Both trees …

## Boundary Traversal of binary tree

Problem Statement   The problem “Boundary Traversal of binary tree” states that you are given a binary tree. Now you need to print the boundary view of a binary tree. Here boundary traversal means that all the nodes are shown as the boundary of the tree. The nodes are seen from …

## Diagonal Traversal of Binary Tree

Problem Statement   The problem “Diagonal Traversal of Binary Tree” states that you are given a binary tree and now you need to find the diagonal view for the given tree. When we see a tree from the top-right direction. The nodes which are visible to us is the diagonal view … 