help me out please
\n Describe your first thoughts on how to solve this problem. \n## Why this is not working \n\n\n# Code\n\nclass Solution {\npublic:\n    // Brute force\n    in
\n<!-- Describe your first thoughts on how to solve this problem. -->\n## Why this is not working \n\n\n# Code\n```\nclass Solution {\npublic:\n    // Brute force\n    int f(int i, string temp, int prev, string s) {\n        int n = s.size();\n        if (i == n) {\n        \n            for (int j = 0; j <= n; j++) {\n                auto it = find(temp.begin(), temp.end(), j + \'0\');\n                if (it == temp.end()) {\n                    if (s[i - 1] == \'D\' && j < prev) \n                    {\n                        return 1;\n                    }\n                    if (s[i - 1] == \'I\' && j > prev){\n                        return 1;\n                    }\n                }\n            }\n            return 0;\n        }\n        int ct = 0;\n        for (int j = 0; j <= n; j++) {\n            auto it = find(temp.begin(), temp.end(), j + \'0\');\n            if (it == temp.end()) {\n                if (s[i] == \'D\' && j > prev) {\n                    temp.push_back(j + \'0\');\n                    ct += f(i + 1, temp, j, s);\n                    temp.pop_back();\n                } else if (s[i] == \'I\' && j < prev) {\n                    temp.push_back(j + \'0\');\n                    ct += f(i + 1, temp, j, s);\n                    temp.pop_back();\n                }\n            }\n        }\n        return ct;\n    }\n\n    int numPermsDISequence(string s) {\n        string temp = "";\n        if (s[0] == \'D\') {\n            return f(0, temp, 0, s);\n        }\n\n        return f(0, temp, s.size(), s);\n    }\n};\n\n```
['C++']