Help!! Why Not Backtracking? Which cases did I miss?
Hi,\nI started with a recursive approach - backtracking until I saw Dynamic Programming tag on the question. Want to know which simulation cases I am missing wh
Hi,\nI started with a recursive approach - backtracking until I saw Dynamic Programming tag on the question. Want to know which simulation cases I am missing when I code it recursively using backtracking - \n\n```\nint count;\n    \n    void backtrack(vector<int>& rollMax, int n, vector<int> & temp){\n        if(n == 0 && temp.size() > 0){\n            count++;\n            return;\n        }\n        for(int i=0;i<6;i++){\n            if(rollMax[i] > 0){\n                temp.push_back(i+1);\n                rollMax[i]--;\n                backtrack(rollMax, n-1, temp);\n                rollMax[i]++;\n                temp.pop_back();\n            }\n        }\n    }\n    \n    int dieSimulator(int n, vector<int>& rollMax) {\n        vector<int> temp;\n        backtrack(rollMax, n,  temp);\n        return count;\n    }\n\n```\n\nThe above code gives outout as 166 for test case ``` n = 3, rollMax = [1,1,1,2,2,3] ```, but it should be 181. Why it won\'t work?
[]