State Transition O(n) Beating 66.67%
IntuitionUse state transition to go from i to i + 1, and finally reach n.Approach
Define 12 variables, which are the state when n === 0: L0T0E0 = 1, L0T0E1 = 0,
# Intuition
Use state transition to go from i to i + 1, and finally reach n.
# Approach
1. Define 12 variables, which are the state when n === 0: L0T0E0 = 1, L0T0E1 = 0, L0T0E2 = 0, L0T1E0 = 0, L0T1E1 = 0, L0T1E2 = 0, L1T0E0 = 0, L1T0E1 = 0, L1T0E2 = 0, L1T1E0 = 0, L1T1E1 = 0, L1T1E2 = 0.
2. Obviously, LxTyEz means there are x Ls, y Ts and z Es. However, when x === 1 or y === 1 or z === 2, it means there are AT LEAST x Ls or AT LEAST y Ts or AT LEAST z Es (full count).
3. Let i go from 1 to n. Use state transition: 
        // lower case variables are of the next state
        const l0t0e0 = L0T0E0 * 23 % modMe
        const l0t0e1 = (L0T0E1 * 23 + L0T0E0 * 1) % modMe
        const l0t0e2 = (L0T0E2 * 24 + L0T0E1 * 1) % modMe
        const l0t1e0 = (L0T1E0 * 24 + L0T0E0 * 1) % modMe
        const l0t1e1 = (L0T1E1 * 24 + L0T0E1 * 1 + L0T1E0 * 1) % modMe
        const l0t1e2 = (L0T1E2 * 25 + L0T0E2 * 1 + L0T1E1 * 1) % modMe
        const l1t0e0 = (L1T0E0 * 24 + L0T0E0 * 1) % modMe
        const l1t0e1 = (L1T0E1 * 24 + L0T0E1 * 1 + L1T0E0 * 1) % modMe
        const l1t0e2 = (L1T0E2 * 25 + L0T0E2 * 1 + L1T0E1 * 1) % modMe
        const l1t1e0 = (L1T1E0 * 25 + L1T0E0 * 1 + L0T1E0 * 1) % modMe
        const l1t1e1 = (L1T1E1 * 25 + L1T1E0 * 1 + L1T0E1 * 1 + L0T1E1 * 1) % modMe
        const l1t1e2 = (L1T1E2 * 26 + L0T1E2 * 1 + L1T0E2 * 1 + L1T1E1 * 1) % modMe
4. When i reaches n, L1T1E2 is the result.
# Complexity
- Time complexity:
O(n)
- Space complexity:
O(1)
# Code
```javascript []
/**
 * @param {number} n
 * @return {number}
 */
var stringCount = function(n) {
    // state when n === 0
    let L0T0E0 = 1, L0T0E1 = 0, L0T0E2 = 0,
        L0T1E0 = 0, L0T1E1 = 0, L0T1E2 = 0,
        L1T0E0 = 0, L1T0E1 = 0, L1T0E2 = 0,
        L1T1E0 = 0, L1T1E1 = 0, L1T1E2 = 0;
    const modMe = 1e9 + 7
    

    for (let i = 1; i <= n; i++) {
        // lower case variables are of the next state
        const l0t0e0 = L0T0E0 * 23 % modMe
        const l0t0e1 = (L0T0E1 * 23 + L0T0E0 * 1) % modMe
        const l0t0e2 = (L0T0E2 * 24 + L0T0E1 * 1) % modMe
        const l0t1e0 = (L0T1E0 * 24 + L0T0E0 * 1) % modMe
        const l0t1e1 = (L0T1E1 * 24 + L0T0E1 * 1 + L0T1E0 * 1) % modMe
        const l0t1e2 = (L0T1E2 * 25 + L0T0E2 * 1 + L0T1E1 * 1) % modMe
        const l1t0e0 = (L1T0E0 * 24 + L0T0E0 * 1) % modMe
        const l1t0e1 = (L1T0E1 * 24 + L0T0E1 * 1 + L1T0E0 * 1) % modMe
        const l1t0e2 = (L1T0E2 * 25 + L0T0E2 * 1 + L1T0E1 * 1) % modMe
        const l1t1e0 = (L1T1E0 * 25 + L1T0E0 * 1 + L0T1E0 * 1) % modMe
        const l1t1e1 = (L1T1E1 * 25 + L1T1E0 * 1 + L1T0E1 * 1 + L0T1E1 * 1) % modMe
        const l1t1e2 = (L1T1E2 * 26 + L0T1E2 * 1 + L1T0E2 * 1 + L1T1E1 * 1) % modMe

        // state transition
        L0T0E0 = l0t0e0
        L0T0E1 = l0t0e1
        L0T0E2 = l0t0e2
        L0T1E0 = l0t1e0
        L0T1E1 = l0t1e1
        L0T1E2 = l0t1e2
        L1T0E0 = l1t0e0
        L1T0E1 = l1t0e1
        L1T0E2 = l1t0e2
        L1T1E0 = l1t1e0
        L1T1E1 = l1t1e1
        L1T1E2 = l1t1e2
    }


    return L1T1E2
};
```
['JavaScript']