# Category Archives: Algorithms

## Min Cost Path | DP-6

Given a cost matrix cost[][] and a position (m, n) in cost[][], write a function that returns cost of minimum cost path to reach (m,… Read More »

## C Program for Min Cost Path

Given a cost matrix cost[][] and a position (m, n) in cost[][], write a function that returns cost of minimum cost path to reach (m,… Read More »

## Java Program for Min Cost Path

Given a cost matrix cost[][] and a position (m, n) in cost[][], write a function that returns cost of minimum cost path to reach (m,… Read More »

## Python Program for Min Cost Path

Given a cost matrix cost[][] and a position (m, n) in cost[][], write a function that returns cost of minimum cost path to reach (m,… Read More »

## Median in a stream of integers (running integers)

Given that integers are read from a data stream. Find median of elements read so for in efficient way. For simplicity assume there are no… Read More »

## Practice Questions for Recursion | Set 6

Question 1 Consider the following recursive C function. Let len be the length of the string s and num be the number of characters printed… Read More »

## Subset Sum | Backtracking-4

Subset sum problem is to find subset of elements that are selected from a given set whose sum adds up to a given number K. We… Read More »

## Check if a number is multiple of 5 without using / and % operators

Given a positive number n, write a function isMultipleof5(int n) that returns true if n is multiple of 5, otherwise false. You are not allowed… Read More »

## Find the repeating and the missing | Added 3 new methods

Given an unsorted array of size n. Array elements are in the range from 1 to n. One number from set {1, 2, …n} is… Read More »

## Optimized Naive Algorithm for Pattern Searching

Question: We have discussed Naive String matching algorithm here. Consider a situation where all characters of pattern are different. Can we modify the original Naive… Read More »

## N Queen Problem | Backtracking-3

We have discussed Knight’s tour and Rat in a Maze problems in Set 1 and Set 2 respectively. Let us discuss N Queen as another… Read More »

## Rat in a Maze | Backtracking-2

We have discussed Backtracking and Knight’s tour problem in Set 1. Let us discuss Rat in a Maze as another example problem that can be… Read More »

## The Knight’s tour problem | Backtracking-1

Backtracking is an algorithmic paradigm that tries different solutions until finds a solution that “works”. Problems which are typically solved using backtracking technique have following… Read More »

## Edit Distance | DP-5

Given two strings str1 and str2 and below operations that can performed on str1. Find minimum number of edits (operations) required to convert ‘str1’ into… Read More »

## A Time Complexity Question

What is the time complexity of following function fun()? Assume that log(x) returns log value in base 2. filter_none edit close play_arrow link brightness_4 code… Read More »