C++ video
\nusing ll = long long;\nclass Solution {\npublic:\n    int sumDistance(vector& nums, string s, int d) {\n        int mod = 1e9+7;\n        vector pos;\n       
\nusing ll = long long;\nclass Solution {\npublic:\n    int sumDistance(vector<int>& nums, string s, int d) {\n        int mod = 1e9+7;\n        vector<int> pos;\n        \n        int n = nums.size();\n        for(int i = 0; i < n; ++i) {\n            if(s[i] == \'L\') pos.push_back(nums[i] - d);\n            else pos.push_back(nums[i] + d);\n        }\n        \n        std::sort(begin(pos), end(pos));\n\n        \n        ll pref_sum = 0;\n\n        ll ans = 0;\n        for(int i = 1; i <n; ++i) {\n            \n            pref_sum += i*((ll)pos[i] - pos[i-1]);\n            ans = (ans + pref_sum) % mod;\n        }\n        \n        return ans;\n    }\n    };\nhttps://youtu.be/vZ2A6cdyFyg\n
['C++']