##
Length of the longest substring without repeating characters
December 2, 2011

Given a string, find the length of the longest substring without repeating characters. For example,

December 2, 2011

Given a string, find the length of the longest substring without repeating characters. For example,

October 30, 2011

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, n) from (0, 0). Each cell of the matrix represents a cost to traverse through that cell.

July 6, 2011

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 ‘str2’. Insert Remove Replace All of the above operations are of equal cost. Examples: Input: str1 = “geek”, str2 = “gesek” Output: 1 We can convert str1 into str2 by… Read More »

June 14, 2011

We have discussed Overlapping Subproblems and Optimal Substructure properties in Set 1 and Set 2 respectively.

June 5, 2011

June 3, 2011

As we discussed in Set 1, following are the two main properties of a problem that suggest that the given problem can be solved using Dynamic programming: 1) Overlapping Subproblems 2) Optimal Substructure We have already discussed Overlapping Subproblem property in the Set 1. Let us discuss Optimal Substructure property here. 2) Optimal Substructure: A… Read More »

June 1, 2011

Dynamic Programming is an algorithmic paradigm that solves a given complex problem by breaking it into subproblems and stores the results of subproblems to avoid computing the same results again.

March 6, 2011

The Fibonacci numbers are the numbers in the following integer sequence.

April 4, 2010

Given a binary matrix, find out the maximum size square sub-matrix with all 1s. For example, consider the below binary matrix. We strongly recommend that you click here and practice it, before moving on to the solution. Algorithm: Let the given binary matrix be M[R][C]. The idea of the algorithm is to construct an auxiliary… Read More »

July 11, 2009

Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, … shows the first 11 ugly numbers. By convention, 1 is included. Given a number n, the task is to find n’th Ugly number. Input : n = 7… Read More »

June 22, 2009

Write an efficient C program to find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum.