


Let ‘N'=3, hence the length of the binary string would be 3.
We can have the following binary strings with no consecutive 1s:
000 001 010 100 101
The first line contains a single integer 'N' denoting the length of the binary string to be generated.
All possible binary strings without consecutive ‘1’ of the length 'N' will be printed in lexicographically increasing order.
You don't need to print anything; it has already been taken care of. Just implement the given function.
Since we need to generate all substrings which does not have consecutive 1s we can simply start adding new characters to the string until the length of the string is ‘K’ taking care that if the last character of the current string is ‘1’ we cannot add another ‘1’ as it will result in consecutive ‘1s.’ Otherwise, if the last character is ‘0’ we have 2 options either to add ‘1’ or ‘0’. We explore both the options recursively until we have a string of desired length i.e ‘K’ .
Our recursive function works as follows: