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