DP with explanation
Intuition and Approach\n\nLet dp[i][x][y][z] represent the number of strings whose length is i and that have x character l\'s, y character e\'s and z character 
# Intuition and Approach\n\nLet `dp[i][x][y][z]` represent the number of strings whose length is `i` and that have `x` character `l`\'s, `y` character `e`\'s and `z` character `t`\'s.\n\nWhen a string has more than 1 character `l`, more than 2 character `e`\'s and more than 1 character `t`, we don\'t care about the exact number of those characters.\n\nSo let\'s tweak the definition of `dp[i][x][y][z]` a little bit.\n\n- `x = 0` means no character `l`.\n- `x = 1` means at least 1 character `l`.\n- `y = 0` means no character `e`.\n- `y = 1` means only 1 character `e`.\n- `y = 2` means at least 2 character `e`\'s.\n- `z = 0` means no character `t`.\n- `z = 1` means at least 1 character `t`.\n\nThen the problem is equivalent to solve `dp[n][1][2][1]`.\n\nWhen calculating `dp[i][x][y][z]`, we need to think about how the last character affects the value of `x`, `y`, or `z`. With that knowledge, we will be able to derive `dp[i][x][y][z]` from `dp[i-1][...][...][...]`.\n\nThe last character can either contribute to an increment to `x` or `y`, or `z` or have no impact on those values.\n\n- When the last character is not one of `l`, `e`, or `t`, it won\'t change the value of `x`, `y`, or `z`.\n- When the last character is `l` and `x` is already 1, it won\'t change the value of `x`, `y`, or `z`.\n- When the last character is `l` and `x` is less than 1, it will cause the value of `x` to increase by 1.\n- When the last character is `e` and `y` is already 2, it won\'t change the value of `x`, `y`, or `z`.\n- When the last character is `e` and `y` is less than 2, it will cause the value of `y` to increase by 1.\n- When the last character is `t` and `z` is already 1, it won\'t change the value of `x`, `y`, or `z`.\n- When the last character is `t` and `z` is less than 1, it will cause the value of `z` to increase by 1.\n\nBased on these, it should be easy to derive the value of `dp[i][x][y][z]` from `dp[i-1][x][y][z]`, `dp[i-1][x-1][y][z]`, `dp[i-1][x][y-1][z]`, and `dp[i-1][x][y][z-1]`.\n\nAlso, note that `dp[i][...][...][...]` only depends on `dp[i-1][...][...][...]`, so it is not necessary to have a 4-dimensional array. You can use two 3-dimensional arrays instead.\n\n# Complexity\n- Time complexity: $O(N*X*Y*Z)$ where $N$ is the required length of the string, $X$ is the number of required character `l`\'s (in this case, it is fixed to 1), $Y$ is the number of required character `e`\'s (in this case, it is fixed to 2), and $Z$ is the number of required character `t`\'s (in this case, it is fixed to 1).\n\n- Space complexity: $O(X*Y*Z)$ where $X$ is the number of required character `l`\'s (in this case, it is fixed to 1), $Y$ is the number of required character `e`\'s (in this case, it is fixed to 2), and $Z$ is the number of required character `t`\'s (in this case, it is fixed to 1).\n\n# Code\n```\nclass Solution:\n    MOD = 10 ** 9 + 7\n    \n    def stringCount(self, n: int) -> int:\n        if n < 4:\n            return 0\n        \n        dp = [[[0] * 2 for i in range(3)] for j in range(2)]\n        dp[0][0][0] = 1\n        \n        for i in range(n):\n            new_dp = [[[0] * 2 for i in range(3)] for j in range(2)]\n            for x in range(2):\n                for y in range(3):\n                    for z in range(2):\n                        missing_count = sum([x != 1, y != 2, z != 1])\n                        new_dp[x][y][z] = (dp[x][y][z] * (26 - missing_count) + \\\n                                          (dp[x - 1][y][z] if x >= 1 else 0) + \\\n                                          (dp[x][y - 1][z] if y >= 1 else 0) + \\\n                                          (dp[x][y][z - 1] if z >= 1 else 0)) % self.MOD\n            dp = new_dp\n        \n        return dp[1][2][1]\n```\n\n## Detailed Explanation of Implementation\n\n```python\n# `misisng_count` means how many characters still have not reached their target count.\n# For example, when `y` is 1, we know we still need at least one character `e`.\nmissing_count = sum([x != 1, y != 2, z != 1])\n\nnew_dp[x][y][z] = (\n    # When the last character is not one of `l`, `e`, or `t`,\n    # or the last chachater is one of the characters that have already reached their target count\n    dp[x][y][z] * (26 - missing_count) + \\\n    \n    # When the last character is `l`\n    (dp[x - 1][y][z] if x >= 1 else 0) + \\\n    \n    # When the last character is `e`\n    (dp[x][y - 1][z] if y >= 1 else 0) + \\\n    \n    # When the last character is `t`\n    (dp[x][y][z - 1] if z >= 1 else 0)\n) % self.MOD\n```
['Python3']