## 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 »Given n dice each with m faces, numbered from 1 to m, find the number of ways to get sum X. X is the summation of values on each face when all the dice are thrown.

Read More »Given two strings ‘X’ and ‘Y’, find the length of the longest common substring. For example, if the given strings are “GeeksforGeeks” and “GeeksQuiz”, the output should be 5 as longest common substring is “Geeks”

Read More »## Dynamic Programming | Set 28 (Minimum insertions to form a palindrome)

32 Comments | Filed under MiscGiven a string, find the minimum number of characters to be inserted to convert it to palindrome.

Read More »## Dynamic Programming | Set 27 (Maximum sum rectangle in a 2D matrix)

44 Comments | Filed under ArraysGiven a 2D array, find the maximum sum subarray in it. For example, in the following 2D array, the maximum sum subarray is highlighted with blue rectangle and sum of this subarray is 29.

Read More »Given a Binary Tree, find size of the Largest Independent Set(LIS) in it. A subset of all tree nodes is an independent set if there is no edge between any two nodes of the subset. For example, consider the following binary tree. The largest independent set(LIS) is {10, 40, 60, 70, 80} and size of […]

Read More »Given a set of non-negative integers, and a value sum, determine if there is a subset of the given set with sum equal to given sum.

Read More »