Home
Gaurav's GitHub Page
Cancel

Connect Nodes at Same Level (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given a binary tree, connect the nodes that are at same level. You’ll be given an addition nextRight pointer for the same. Initially, all the nextRight pointers point to garba...

Vertical Tree Traversal (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given a Binary Tree, find the vertical traversal of it starting from the leftmost level to the rightmost level. If there are multiple nodes passing through a vertical line, the...

Bottom View of Binary Tree (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given a binary tree, return an array where elements represent the bottom view of the binary tree from left to right. Note: If there are multiple bottom-most nodes for a horizo...

Diameter of a Binary Tree (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION The diameter of a tree (sometimes called the width) is the number of nodes on the longest path between two end nodes. geeksforgeeks SOLUTION The key idea is to compute the h...

Array to BST (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given a sorted array. Convert it into a Height Balanced Binary Search Tree (BST). Return the root of the BST. Height-balanced BST means a binary tree in which the depth of the...

Lowest Common Ancestor in a BST (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given a Binary Search Tree (with all values unique) and two node values n1 and n2 (n1!=n2). Find the Lowest Common Ancestors of the two nodes in the BST. geeksforgeeks SOLUTI...

Symmetric Tree (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given a Binary Tree. Check whether it is Symmetric or not, i.e. whether the binary tree is a Mirror image of itself or not. geeksforgeeks SOLUTION create helper method isSam...

Kth largest element in BST (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given a Binary Search Tree. Your task is to complete the function which will return the Kth largest element without doing any modification in Binary Search Tree. geeksforgeeks...

Identical Trees (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given two binary trees, the task is to find if both of them are identical or not. geeksforgeeks SOLUTION class Solution { boolean isIdentical(Node root1, Node root2) ...

Height of Binary Tree (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given a binary tree, find its height. geeksforgeeks SOLUTION class Solution { int height(Node node) { return node == null ? 0 : 1 + Math.max(height(node.lef...