[algogeeks] Need an optimized solution.

2013-10-17 Thread pankaj joshi
HI All, Puzzle: (This puzzle is of hacker rank) Harvey gives two numbers N and K and defines a set A. *A = { x : x is a natural number ≤ N }* (i.e), A = {1,2,3,4,5,6,…., N} Mike has to find the total number of pairs of elements A[i] and A[j] belongi

Re: [algogeeks] Breaking a string problem (Dynamic programming)

2013-10-17 Thread kumar raja
I have find out the minimum cost using the recurrence relation S[i,j] = |j-i+1| + min ( s[i,k]+s[k+1,j]) for all i<=k wrote: > Question seems similar to matrix chain multiplication problemhere you > need to find min cost.. > Recurrence for this could be the following , please validate it. > >