Skip to content

Instantly share code, notes, and snippets.

View hrishikesh-mishra's full-sized avatar

Hrishikesh Mishra hrishikesh-mishra

View GitHub Profile
@hrishikesh-mishra
hrishikesh-mishra / BinaryTreeMirrorWithoutRecursion.java
Created April 15, 2017 15:10
Mirror image of binary tree without Recursion
package com.hrishikesh.practices.binarytree;
import java.util.LinkedList;
import java.util.Objects;
import java.util.Queue;
/**
* Problem:
* Mirror image of binary tree without Recursion
*
@hrishikesh-mishra
hrishikesh-mishra / BinaryTreeMaximumPathSum.java
Created April 15, 2017 15:07
Binary Tree Maximum Path Sum
package com.hrishikesh.practices.binarytree;
import java.util.Objects;
/**
* Binary Tree Maximum Path Sum
* For a binary tree, find the maximum path sum. The path may start and end at any node in the tree.
*
* @author hrishikesh.mishra
*/
@hrishikesh-mishra
hrishikesh-mishra / BinaryTreeDistanceBetweenTwoNodes.java
Created April 15, 2017 15:04
Binary Tree Distance between Two Nodes
package com.hrishikesh.practices.binarytree;
import java.util.Objects;
/**
* Problem:
* Binary Tree Distance between Two Nodes
* ;
* Find the Distance between Two Nodes of a Binary Tree.
*
@hrishikesh-mishra
hrishikesh-mishra / BinaryTreeBoundaryTraversal.java
Created April 15, 2017 15:01
Binary Tree Boundary Traversal
package com.hrishikesh.practices.binarytree;
import java.util.Objects;
/**
* Problem:
* Binary Tree Boundary Traversal
* ;
* Hint: Problem is divided into three sections
* - Left side view
@hrishikesh-mishra
hrishikesh-mishra / BinaryTreeDiagonalTraversal.java
Created April 15, 2017 14:57
Binary Tree Diagonal Traversal
package com.hrishikesh.practices.binarysearchtree;
import com.hrishikesh.practices.binarytree.BTPrinter;
import com.hrishikesh.practices.binarytree.BinaryTreeNode;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@hrishikesh-mishra
hrishikesh-mishra / BinarySearchTreeTwoOutOfOrderNode.java
Created April 15, 2017 14:52
In Binary Search Tree two nodes are out of order
package com.hrishikesh.practices.binarysearchtree;
import com.hrishikesh.practices.binarytree.BTPrinter;
import com.hrishikesh.practices.binarytree.BinaryTreeNode;
import java.util.Objects;
/**
* Problem:
* In Binary Search Tree two nodes are out of order
@hrishikesh-mishra
hrishikesh-mishra / SkipList.java
Created March 14, 2017 12:29
SkipList java implementation
package com.hrishikesh.ns.list;
import java.util.*;
/**
*
* A SkipList S for a map M consists of a series of list {S0, S1, ......, Sh}. Each list Si
* stores a subset of the entries of M sorted by increasing keys, plus entries with two sentinels
* keys denoted -infinities to +infinities, where-infinities is smaller than every possible keys that
* can be inserted in M and +infinities is larger than every possible keys that can be inserted in M.
@hrishikesh-mishra
hrishikesh-mishra / ListNthFinder.java
Created March 14, 2017 12:29
Find nth node from last in singly linked list in one scan.
package com.hrishikesh.ns.list;
import java.util.Objects;
/**
* Problem:
* Find nth node from last in singly linked list in one scan.
*
* @author hrishikesh.mishra
* @link http://hrishikeshmishra.com/find-nth-node-from-last-in-singly-linked-list-in-one-scan/
@hrishikesh-mishra
hrishikesh-mishra / LoopDetector.java
Created March 14, 2017 12:29
How to find the starting point of a loop in a linked list.
package com.hrishikesh.ns.list;
import java.util.Objects;
/**
* Problem:
* How to find the starting point of a loop in a linked list.
*
* @author hrishikesh.mishra
* @link http://hrishikeshmishra.com/how-to-find-the-starting-point-of-a-loop-in-a-linked-list/
@hrishikesh-mishra
hrishikesh-mishra / ReverseSinglyLinkedList.java
Created March 14, 2017 12:29
Reverse a singly linked list.
package com.hrishikesh.ns.list;
import java.util.Objects;
/**
* Problem:
* Reverse a singly linked list.
*
* @author hrishikesh.mishra
* @link http://hrishikeshmishra.com/reverse-a-singly-linked-list/