Home
Gaurav's GitHub Page
Cancel

3 sum

This question is part of NeetCode150 series. Problem Description Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i]...

Right Smaller Than

PROBLEM DESCRIPTION Write a function that takes in an array of integers and returns an array of the same length where each element in the output array corresponds to the number of integers in the ...

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...