This is a very simple problem, given a number, we need to find the number of ways to reach it using increments of 1 and 2, given consecutive 1s not allowed.
Go through these two problems first to get the complete idea:
Number of ways to reach a given number using increments of 1 and 2
Number of ways to reach a number using increments of 1 and 2 (consecutive 2s are not allowed)
Consider this example to understand the problem clearly:
4
4 can be arrived as:
2+2
1+2+1
1+1+2 (not allowed)
5
5 c...
Published on October 29, 2020 01:36