[Java] Simple and clean DP solution with example
Solution:\n\n    public int dieSimulator(int n, int[] rollMax) {\n        int[][] dp = new int[n + 1][7];\n        Arrays.fill(dp[0], 1);\n\n        for (int i 
Solution:\n```\n    public int dieSimulator(int n, int[] rollMax) {\n        int[][] dp = new int[n + 1][7];\n        Arrays.fill(dp[0], 1);\n\n        for (int i = 1; i <= n; i++) {\n            for (int j = 0; j <= 6; j++) {\n                for (int m = 1; m <= 6; m++) {\n                    if (m == j) continue;\n                    for (int k = 1; k <= rollMax[m-1] && i >= k; k++) {\n                        dp[i][j] = (dp[i][j] + dp[i-k][m]) % 1000000007;\n                    }\n                }\n            }\n        }\n        return dp[n][0];\n    }\n```\n\nVariables:      \n\n\ti - number of rolls\n    j - dice value [1-6]\n    m - dice value [1-6] before the suffix of similar rolls, at index [i-k]\n    k - length of the suffix of the similar numbers for j dice value\n\t\n\tdp[n][0] contains the answer for the current roll\n\nExample for input:\n```\n 4\n[4,4,4,4,2,3]\n```\n\nDP matrix:\n```\nAns: \n[1,    1,    1,    1,    1,    1,    1]\n[6,    5,    5,    5,    5,    5,    5]\n[36,   30,   30,   30,   30,   30,   30]\n[215,  179,  179,  179,  179,  180,  179]\n[1284, 1069, 1069, 1069, 1069, 1074, 1070]\n```\n
[]