I was looking at this question:
Given a length n, return the number of strings of length n that can be made up of the letters 'a', 'b', and 'c', where there can only be a maximum of 1 'b's and can only have up to two consecutive 'c's
For instance, given
n = 3, the following are valid combinations:
Someone answering the question listed
n * n + (n - 1) * (n - 1) + (n + 1) as an answer, but I do not understand how it was derived.