Here is the Question Link from Ittiam Think challenge 2017 on Hackerearth
I attempted this problem but it got partially accepted.I can change my recursive approach to iterative one to avoid TLE but I don’t know why I am getting WA in some of test cases with this solution.
yes,I did.I understood how we can reduce it to another problem, but was having difficulty in understanding how 1d dp mask was able to compute everything(dp state wasn’t clear to me).Thanks!
Thanks a lot! @meoow I made this silly mistake and was searching for error in code from long @vijju123 I think I got ACs since there are many test cases where the result would be less than 1e9+7