The DP solution to this problem is very similar DP solution for counting the
number of Dyck words with some additional conditions.

while calculating DP[i][j]  you need to check if i+j equals one from the
list of k values. if yes copy the value from the prev row(i.e DP[i-1][j])
instead of assigning it to DP[i-1][j] + DP[i][j-1] since we can add only an
a  '(' in position i+j and no ')' can be placed there



On Wed, Jan 26, 2011 at 11:07 PM, Avayukth <suresh_iyeng...@yahoo.com>wrote:

> How do we solve the problem http://www.spoj.pl/problems/SQRBR/ using
> dynamic programming?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to