If you need hint:
I used DP (Dynamic Programming) to solve this and get AC (Accepted). I
stored the matrix as 2-D array and then started with array[R][C]. From
there I can go upward and left. In each element of array put the minimum
possible value to get the array[R][C]. In case, if we get the
Take an array of size Min[N+1][S+1]
where, N is the total no. of unique denominations and S is the total
sum
Let the value array be V[N]; // let it be 1- based indexed for ease of
explanation in the below given code snippet.
Initialize the following:
a) for (i =0; i = N; ++i)
Min[i][0]
Use complete search, add memoization and you have a top-down dynamic
programming solution ready.
- lets say we have division positions in an array cuts[]
- start and end will identify the position of current cut (taken from
cuts[] array)
- initialize memo[][] array to INT_MAX, this is the place
what about printing these strings onto terminal. can printing of the
string is also similar. I tried to develop the algo but got messed
up.can some one help?
On Aug 8, 2:53 am, Amir hossein Shahriari
amir.hossein.shahri...@gmail.com wrote:
@ankur: dp[i][j] number of (prefix) strings that have i