Home
Gaurav's GitHub Page
Cancel

Multi String Search (Trie)

PROBLEM DESCRIPTION You are given a Big String and an array of small strings. You need to check whether each small string is present in the big string. Do not use any in-built method. SOLUTION W...

Trie - Introduction - Part 2

INTRODUCTION TO TRIE - PART 2 Trie Introduction: Part 1 Implementation leetcode public class Trie { Node root; class Node{ boolean isEnd; Map<Character, N...

Trie - Introduction - Part 1

INTRODUCTION TO TRIE - PART 1

Populating Next Right Pointers in Each Node - Perfect Binary Tree

PROBLEM DESCRIPTION You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. Populate each next pointer to point to its next right node. If th...

Binary Tree Maximum Path Sum

PROBLEM DESCRIPTION A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence at most onc...

Validate Three Nodes in BST

PROBLEM DESCRIPTION You are given three Nodes of a BST - NodeOne, NodeTwo and NodeThree. Write a function that returns true if one of NodeOne and NodeThree is an ancestor of NodeTwo. The other Nod...

Lowest Common Ancestor - Using In-time and Out-time

PROBLEM DESCRIPTION Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defin...

Lowest Common Ancestor of a Binary Search Tree

PROBLEM DESCRIPTION Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST. According to the definition of LCA on Wikipedia: “The lowest common...

Morris Traversal

PROBLEM DESCRIPTION Binary Tree traversal using Morris Algorithm. Iterative approach, no stack required - O(1) space complexity. geeksforgeeks SOLUTION Using Morris Traversal, we can traverse th...

Construct Binary Tree from Inorder and Postorder Traversal

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