【47ms Beat100%】I hope there is no modulo!
Intuition\n\n\n\n# Code\n\nclass Solution {\npublic:\n    int sumDistance(vector<int>& ss, string s, int d) {\n        ios::sync_with_stdio(false);cin.tie(0);co
# Intuition\n![image.png](https://assets.leetcode.com/users/images/279e4a21-038b-422d-a606-585dcda4a668_1719882675.3985534.png)\n\n\n# Code\n```\nclass Solution {\npublic:\n    int sumDistance(vector<int>& ss, string s, int d) {\n        ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n        const int n=s.size();\n        const int MOD = 1000000007;\n        vector<long long> nums(ss.begin(),ss.end());\n        for(int i=0;i<n;++i){\n            if(s[i]==\'R\'){\n                nums[i]+=d;\n            }else{\n                nums[i]-=d;\n            }\n        }\n        sort(nums.begin(),nums.end());\n        int ans=0;\n        for(uint i=0;i<=n-2;++i){\n            ans=(ans+(nums[i+1]-nums[i])%MOD*(i+1)*(n-i-1))%MOD;\n        }\n        return ans;\n    }\n};\n```
['C++']