4 Rules For the outer loop, count the no of lines For the inner loop, focus on the no of columns Print the ‘*” inside the inner for loop Observe...
Problem Given the root of a binary tree, return the length of the diameter of the tree. The diameter of a binary tree is the length of the longest...
Problem statement Given a binary tree, determine if it is height-balanced.(link) Example 1: Input: root = [3,9,20,null,null,15,7] Output:...
Problem Given the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes along the longest path from...
Here we illustrates the implementation of DFS iteratively using stacks. For the recursive implementation of DFS refere this article. Preorder...
Introduction Arrays and linked lists are flat structures, whereas a tree is a hierarchical structure. If a tree has only 2 children, then it is...