Cpp Solution | O(A) Time | O(1) Space


#1
int Solution::solve(int A) {
    long same = 12,diff = 24;
    int mod = 1e9 + 7;
    while(--A) {
        long same2 = (5*diff + 7*same)%mod;
        long diff2 = (11*diff + 10*same)%mod;
        same = same2;
        diff = diff2;
    }
    return (same+diff)%mod;
}