there’s a run-time error for test case -7
i don’t know why.
please check
link- https://ide.codingblocks.com/s/258572
Run-time error again
hello @S18CRX0174
please reshare ur code .
the link u have shared contains two different code,pls check and share the correct link
your code is correct both logically as well as implementation wise,
in last test case it is failing because of two much memory allocation
why too much memory allocation,as you can see i have decreased pattern length
see contraint in worst case dp size will be around 100000000
so how to correct this
we can try bottom up aprroach.
if still it fails then we can try some memory optimisation.
one observation for space optimisation is->
answer for current row depends only on current row and the last row so instead of use 2 d array of size N XM , we can use dp array of size 2 X N . where out of these two rows one will store answer for previous state and other row will store answer for current row
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.