here’s my code https://ide.codingblocks.com/s/246596
Getting TLE - used recursion
@Ishitagambhir
The constraints are large, so using a recursive solution takes exponential time and will give TLE.
Also your recurrence relation is not correct, for every element you have 2 choices whether it should be 0 or 1, if it is 1 then the consecutive element can’t be 1. So there will be restriction for the next recursive call that whether we can take 1 or not here.
You can have a look at my code for how recursive calls are made if not understood, https://ide.codingblocks.com/s/246604