Home
Gaurav's GitHub Page
Cancel

Minimum Genetic Mutation

PROBLEM DESCRIPTION A gene string can be represented by an 8-character long string, with choices from ‘A’, ‘C’, ‘G’, and ‘T’. Suppose we need to investigate a mutation from a gene string startGene...

Snakes and Ladders

PROBLEM DESCRIPTION You are given an n x n integer matrix board where the cells are labeled from 1 to n2 in a Boustrophedon style starting from the bottom left of the board (i.e. board[n - 1][0]) ...

Evaluate Division

PROBLEM DESCRIPTION You are given an array of variable pairs equations and an array of real numbers values, where equations[i] = [Ai, Bi] and values[i] represent the equation Ai / Bi = values[i]. ...

Search Insert Position

PROBLEM DESCRIPTION Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. ...

Minimum Absolute Difference in BST

PROBLEM DESCRIPTION Given the root of a Binary Search Tree (BST), return the minimum absolute difference between the values of any two different nodes in the tree. leetcode SOLUTION We should b...

Lowest Common Ancestor of a Binary Tree

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

Binary Search Tree Iterator

PROBLEM DESCRIPTION Implement the BSTIterator class that represents an iterator over the in-order traversal of a binary search tree (BST): -BSTIterator(TreeNode root) Initializes an object of the...

Count Complete Tree Nodes

PROBLEM DESCRIPTION Given the root of a complete binary tree, return the number of the nodes in the tree. According to Wikipedia, every level, except possibly the last, is completely filled in a ...

Sum Root to Leaf Numbers

PROBLEM DESCRIPTION You are given the root of a binary tree containing digits from 0 to 9 only. Each root-to-leaf path in the tree represents a number. Return the total sum of all root-to-leaf num...

Flatten Binary Tree to Linked List

PROBLEM DESCRIPTION Given the root of a binary tree, flatten the tree into a “linked list”: The “linked list” should use the same TreeNode class where the right child pointer points to the nex...