ques: https://hack.codingblocks.com/contests/c/547/875
code: https://ide.codingblocks.com/s/58225
I don’t think there’s a need of a 2D DP here as contraints are very small. But I maybe wrong
ques: https://hack.codingblocks.com/contests/c/547/875
code: https://ide.codingblocks.com/s/58225
I don’t think there’s a need of a 2D DP here as contraints are very small. But I maybe wrong
Hi Kunal, since your code is working fine for sample test case, and giving TLE on submission, you will need to use DP to further optimise your code. Try to do it using 1D DP.
so u mean a DP of strings to check repeated cases in a base case or on every recursive call
You can use bottom-up approach for this problem. You can create two arrays - one for a and one for b, and you can update the values for every iteration.