Count n.o of binary strings

am not getting correct output please correct and comment the mistakes in my code
i have commented my steps
https://ide.codingblocks.com/s/43978

https://hack.codingblocks.com/contests/c/512/1272

Hey Jay, your this approach is not working as it is not giving the correct recurrence relation and there is no need to use 2D DP for this problem, you can solve this problem using 1D DP only by taking 2 arrays of size n.
And recurrence relation for this problem is

arr1[i] = arr1[i - 1] + arr2[i - 1]
arr2[i] = arr1[i - 1] 

One more thing is if you observe carefully, you will find that the count is (n+2)th fibonacci number for n >= 1, So you can use that approach also.

Hope this helps you :slight_smile: