Home
Gaurav's GitHub Page
Cancel

Binary Tree Right Side View

PROBLEM DESCRIPTION Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. Leetcode SOLUTION ...

Kth Smallest Element in a BST

PROBLEM DESCRIPTION Given the root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) of all the values of the nodes in the tree. Leetcode SOLUTION APPROACH 1 ...

Equal Tree Partition - Binary Tree

PROBLEM DESCRIPTION Given the root of a binary tree, return true if you can partition the tree into two trees with equal sums of values after removing exactly one edge on the original tree. leetco...

Recover Binary Search Tree

PROBLEM DESCRIPTION Two elements of a binary search tree (BST), represented by root A are swapped by mistake. Tell us the 2 values swapping which the tree will be restored. interviewbit SOLUTION ...

Least Common Ancestor - Binary Tree

PROBLEM DESCRIPTION Find the lowest common ancestor in an unordered binary tree A, given two values, B and C, in the tree. Leetcode SOLUTION Get root to node path: YouTube In the previous s...

Valid Binary Search Tree

PROBLEM DESCRIPTION Given the root of a binary tree, determine if it is a valid binary search tree (BST). leetcode SOLUTION public class Solution { public int isValidBST(TreeNode A) { ...

Delete a Node in Binary Search Tree

PROBLEM DESCRIPTION Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST. leetcode SOLUTION...

Construct Binary Tree from Preorder and Inorder Traversal

PROBLEM DESCRIPTION Given two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the same tree, construct and ret...

Vertical Order Traversal - Binary Tree

PROBLEM DESCRIPTION Given a binary tree, return a 2-D array with vertical order traversal of it. SOLUTION public class Solution { public ArrayList<ArrayList<Integer>> verti...

Binary Tree - Level Order Traversal II

PROBLEM DESCRIPTION Given the root of a binary tree, return the level order traversal of its nodes’ values. (i.e., from left to right, level by level). Leetcode SOLUTION For the main explainatio...