[Python3] DP | 12 Combinations | O(N)
Approach\nWe enumerate all possible scenarios (12 in total), and use DP to get the final results. dp[i][j] represents the number of possible valid strings of le
# Approach\nWe enumerate all possible scenarios (12 in total), and use DP to get the final results. `dp[i][j]` represents the number of possible valid strings of length `i` under scenario `j`.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def stringCount(self, n: int) -> int:\n        MOD = 10 ** 9 + 7\n        # (l, e, t) count = (0, 0, 0), (0, 0, 1+), (0, 1, 0), (1+, 0, 0), (0, 1, 1+), (1+, 0, 1+), (1+, 1, 0), (0, 2+, 0), (1+, 1, 1+), (0, 2+, 1+), (1+, 2+, 0), (1+, 2+, 1+)\n        dp = [[0] * 12 for _ in range(n + 1)]\n        dp[1][0] = 23\n        dp[1][1] = dp[1][2] = dp[1][3] = 1\n        for i in range(2, n + 1):\n            dp[i][0] = dp[i - 1][0] * 23\n            dp[i][1] = dp[i - 1][0] + dp[i - 1][1] * 24\n            dp[i][2] = dp[i - 1][0] + dp[i - 1][2] * 23\n            dp[i][3] = dp[i - 1][0] + dp[i - 1][3] * 24\n            dp[i][4] = dp[i - 1][1] + dp[i - 1][2] + dp[i - 1][4] * 24\n            dp[i][5] = dp[i - 1][1] + dp[i - 1][3] + dp[i - 1][5] * 25\n            dp[i][6] = dp[i - 1][2] + dp[i - 1][3] + dp[i - 1][6] * 24\n            dp[i][7] = dp[i - 1][2] + dp[i - 1][7] * 24\n            dp[i][8] = dp[i - 1][4] + dp[i - 1][5] + dp[i - 1][6] + dp[i - 1][8] * 25\n            dp[i][9] = dp[i - 1][4] + dp[i - 1][7] + dp[i - 1][9] * 25\n            dp[i][10] = dp[i - 1][6] + dp[i - 1][7] + dp[i - 1][10] * 25\n            dp[i][11] = dp[i - 1][8] + dp[i - 1][9] + dp[i - 1][10] + dp[i - 1][11] * 26\n            for j in range(12):\n                dp[i][j] %= MOD\n        return dp[n][11]\n```
['Dynamic Programming', 'Python3']