Not getting the logic
Hello Gurdeep,
you can think a recursive solution.
let say f(n) is a function that will tell us number of ways to make n digit number such that no two b’s are consecutive.
lets break the problem
case A) when we put a at nth position then our problem will break to f(n-1).
case B) when we put b at nth positon then we should place a at (n-1)th place therefore our problem will break to f(n-2)
so our final answer for f(n) will be summation of both the cases.
i.e f(n)= f(n-1)+f(n-2) (this recurrence looks familiar?)