Beat 90% Time | Clean & Concise
Code\n\nclass Solution {\npublic:\n    int MOD = 1000000007;\n    int sumDistance(vector<int>& num, string s, int d) {\n        vector<long> nums;\n        for(
# Code\n```\nclass Solution {\npublic:\n    int MOD = 1000000007;\n    int sumDistance(vector<int>& num, string s, int d) {\n        vector<long> nums;\n        for(auto x: num) nums.push_back(x);\n\n        for(int i=0; i<nums.size(); ++i){\n            if(s[i]==\'R\') nums[i] += d;\n            else nums[i] -= d;\n        }\n        sort(nums.begin(),nums.end());\n        long ans = 0;\n        for(int i=0; i<nums.size()-1; ++i){\n            ans = (ans + ((nums.size()-i-1)%MOD)*((nums[i+1]-nums[i])%MOD)*(i+1))%MOD;\n        }\n        return (int) ans;\n    }\n};\n```
['C++']