#
Algorithm Archive

I have been posting data structure and algorithms programs on various topics such as Array,Queue, Stack ,Binary tree, LinkedList , String, Number, ArrayList, etc. So I am consolidating list of programs to create an index …

In this post, we will see how to print all paths from top left to bottom right of MxN matrix. Problem We need to print all paths from top left to bottom right of MxN matrix. …

In this post, we will see how to print numbers from 1 to N without using loop. Problem Print number from 1 to N without using any loop. N=10 Output: 1 2 3 4 5 …

In this post, we will see how to find all subsets of set or power set in java. Problem Given a set of distinct integers, arr, return all possible subsets (the power set). For example: Input: nums …

In this post, we will see how to find all permutations of the array in java. Problem 1 Given array of distinct integers, print all permutations of the array. For example: array : Permuations are …

In this post, we will see about how to count all paths from top left to bottom right of MxN matrix. Problem We need to count all paths from top left to bottom right of MxN …

In this tutorial, we will see about Memoization example in java. Let me start with the question. Would you like to do same task again and again when you know that it is going to …

In this post, we will see how to find Intersection of two linked lists. Problem Given two singly linked lists, find if two linked lists intersect. If they intersect, find intersection point. Solution Here is simple …

In this post, we will see LRU cache implementation in java. Problem Design a Least recently used cache implementation in java. It should have below properties. bounded size: It should have bounded size to take care …

In this tutorial, we will see how to count trailing zeros in factorial of a number in java. Problem Count number of zeros in factorial of number in java. For example: Factorial of 6 is …

In this post, we will see Dijkstra algorithm for find shortest path from source to all other vertices. Problem You will be given graph with weight for each edge,source vertex and you need to find …