ANYONE CAN MODIFY THIS BFS approach with TLE?
\nclass Solution {\npublic:\n    int numPermsDISequence(string s) {\n        int n=s.length();\n        queue<pair<string,unordered_set<int>>> q;\n        unord
```\nclass Solution {\npublic:\n    int numPermsDISequence(string s) {\n        int n=s.length();\n        queue<pair<string,unordered_set<int>>> q;\n        unordered_set<int> v;\n        string str="";\n        for(int i=0;i<=n;++i)\n        {\n            str="";\n            v.clear();\n            str+=(i+\'0\');\n            v.insert(i);\n            q.push({str,v});\n        }\n        int i=0;\n        unordered_set<string> visall;\n        while(!q.empty())\n        {\n            int sz=q.size();\n            if(i==n)\n            {\n                return q.size();\n            }\n            while(sz--)\n            {\n                auto temp=q.front();\n                q.pop();\n                if(visall.find(temp.first)!=visall.end())\n                {\n                    continue;\n                }\n                if(s[i]==\'D\')\n                {\n                    for(int j=temp.first.back()-\'0\'-1;j>=0;--j)\n                    {\n                        if(temp.second.find(j)==temp.second.end())\n                        {\n                            temp.first+=(j+\'0\');\n                            temp.second.insert(j);\n                            if(visall.find(temp.first)==visall.end())\n                            {\n                                q.push({temp.first,temp.second});\n                            }\n                            temp.second.erase(j);\n                            temp.first.pop_back();\n                        }\n                    }\n            }\n                else\n                {\n                    for(int j=temp.first.back()-\'0\'+1;j<=n;++j)\n                    {\n                        if(temp.second.find(j)==temp.second.end())\n                        {\n                            temp.first+=(j+\'0\');\n                            temp.second.insert(j);\n                            if(visall.find(temp.first)==visall.end())\n                            {\n                                q.push({temp.first,temp.second});\n                            }\n                            temp.second.erase(j);\n                            temp.first.pop_back();\n                        }\n                    }\n                }\n            }\n            i++;\n        }\n        return 0;\n    }\n};\n```
['Breadth-First Search', 'C']