Can someone please explain the dynamic programing solution to this problem. asked 04 Nov '16, 13:11 ![]()
|
This problem can be solved by knowledge of 'Catalan Number'. You can read on this: http://www.geeksforgeeks.org/applications-of-catalan-numbers/ and https://en.wikipedia.org/wiki/Catalan_number . Here is dynamic solution to find n'th catalan number:
answered 04 Nov '16, 13:41 ![]()
|
You could also check out this article on catalan numbers.As catalan numbers are defined recursively it can be easily converted into itarative dp(similar to fibonacci).Just undestand how we arrive at the series coding this into dp is quite intutive. for solution you may refer to geeksforgeeks. answered 04 Nov '16, 14:07 ![]()
|
This was the function I used in Java:
answered 04 Nov '16, 20:45 ![]()
|