Company: Infosys_13july
Difficulty: medium
Flip Flop Arrays Problem Description You are given three integers N, L and R. It is given that a flip flop array is defined as an array of length N such that: Each element is between L and R (inclusive). There are no two adjacent values that are equal (i.e., for all valid i , A[i] != A[i+1] ). No three adjacent values that are strictly increasing or strictly decreasing (i.e., for all valid i , it's not true that A[i] < A[i+1] < A[i+2] AND it's not true that A[i] > A[i+1] > A[i+2] ). Moreover, it is guaranteed that L < R. Find the total number of possible flip flop arrays of size N. Since the answer can be large return it modulo 10^9 + 7. Input Format The first line contains an integer, N, denoting the length of the array. The next line contains an integer, L, denoting the lower bound. The next line contains an integer, R, denoting the upper bound. Examples Example 1: Input: 3 1 2 Output: 2 Explanation: N=3, L=1, R=2 The arrays are: [1, 2, 1] [2, 1, 2] Because for all i,