Given a number N, find the number of binary strings of length N that contains consecutive 1's in them.
Input:N = 2Output:1Explanation:There are 4 strings of length 2, the strings
are 00, 01, 10, and
11. Only the string 11
has consecutive 1's.
Input:N = 5Output:19Explanation:There are 19 stringshaving consecutive 1's.
You don't need to read input or print anything. Your task is to complete the function numberOfConsecutiveOnes() which takes an integer N and returns the number of binary stringsthat contain consecutive 1's in them.
Expected Time Complexity: O(N) Expected Auxiliary Space: O(N)