c++ || easy || prefix sum
\nclass Solution {\npublic:\n    int sumDistance(vector<int>& nums, string s, int d) {       \n        \n        int n = nums.size();                \n        v
```\nclass Solution {\npublic:\n    int sumDistance(vector<int>& nums, string s, int d) {       \n        \n        int n = nums.size();                \n        vector <long long int> nums2(nums.begin(), nums.end());\n        for(int i=0; i<n; i++)\n        {\n            if(s[i]==\'R\')            \n                nums2[i]+=d;\n            else\n                nums2[i]-=d;\n        }            \n        sort(nums2.begin(), nums2.end());        \n        long long int sum = 0;        \n        for(int i=1; i<n; i++)\n        {                    \n            sum += ( (i*nums2[i]) - nums2[i-1] );            \n            sum %= (long long)(1e9 + 7) ; \n            nums2[i] += nums2[i-1];  \n        }        \n        return sum;\n    }\n};\n```
['Array', 'Math', 'C', 'Iterator', 'Prefix Sum']