## Shortest path with exactly k edges in a directed and weighted graph

Leave a comment | Filed under GraphGiven a directed and two vertices ‘u’ and ‘v’ in it, find shortest path from ‘u’ to ‘v’ with exactly k edges on the path.

Read More »## Count all possible walks from a source to a destination with exactly k edges

Leave a comment | Filed under GraphGiven a directed graph and two vertices ‘u’ and ‘v’ in it, count all possible walks from ‘u’ to ‘v’ with exactly k edges on the walk.

Read More »Let 1 represent ‘A’, 2 represents ‘B’, etc. Given a digit sequence, count the number of possible decodings of the given digit sequence.

Read More »Given a positive integer N, count all possible distinct binary strings of length N such that there are no consecutive 1′s.

Read More »Catalan numbers are a sequence of natural numbers that occurs in many interesting counting problems like following.

Read More »## Remove minimum elements from either side such that 2*min becomes more than max

Leave a comment | Filed under ArraysGiven an unsorted array, trim the array such that twice of minimum is greater than maximum in the trimmed array. Elements should be removed either end of the array.

Read More »## Count all possible paths from top left to bottom right of a mXn matrix

12 Comments | Filed under ArraysThe problem is to count all the possible paths from top left to bottom right of a mXn matrix with the constraints that from each cell you can either move only to right or down

Read More »Travelling Salesman Problem (TSP): Given a set of cities and distance between every pair of cities, the problem is to find the shortest p

Read More »Given a rope of length n meters, cut the rope in different parts of integer lengths in a way that maximizes product of lengths of all parts. You must make at least one cut. Assume that the length of rope is more than 2 meters.

Read More »Given a set of numbers, find the Length of the Longest Arithmetic Progression (LLAP) in it.

Read More »A car factory has two assembly lines, each with n stations. A station is denoted by Si,j where i is either 1 or 2 and indicates the assembly line the station is on, and j indicates the number of the station.

Read More »## Dynamic Programming | Set 33 (Find if a string is interleaved of two other strings)

76 Comments | Filed under StringsGiven three strings A, B and C. Write a function that checks whether C is an interleaving of A and B.

Read More »Given an input string and a dictionary of words, find out if the input string can be segmented into a space-separated sequence of dictionary words. See following examples for more details.

Read More »Problem statement: Consider a row of n coins of values v1 . . . vn, where n is even. We play a game against an opponent by alternating turns. In each turn, a player selects either the first or last coin from the row,

Read More »