C++ STL partial_sum, 0ms
class Solution {\n    public:\n        int numPermsDISequence(string S) {\n            int n = S.size() + 1, d = 0, i = 0;\n            vector<int> arr(n, 1);\n
    class Solution {\n    public:\n        int numPermsDISequence(string S) {\n            int n = S.size() + 1, d = 0, i = 0;\n            vector<int> arr(n, 1);\n            auto func = [](int a, int b) { return (a + b) % 1000000007; };\n            for (char c : S) {\n                if (c == \'D\') {\n                    ++d;\n                    partial_sum(arr.rbegin() + i, arr.rend() - d, arr.rbegin() + i, func);\n                } else {\n                    ++i;\n                    partial_sum(arr.begin() + d, arr.end() - i, arr.begin() + d, func);\n                }\n            }\n            return *(arr.begin() + d);\n        }\n    };
[]