SIMPLE || AVOID COLLISION || C++
Code\n\nclass Solution {\npublic:\n    int sumDistance(vector<int>& nums, string s, int d) {\n        int i = 0, n = nums.size();\n        for(i = 0; i < n; i++
# Code\n```\nclass Solution {\npublic:\n    int sumDistance(vector<int>& nums, string s, int d) {\n        int i = 0, n = nums.size();\n        for(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        long long ans = 0,mod = 1e9+7,p = 0;\n        for(i = 0; i < n; i++){\n            ans = (((ans+(nums[i]*1LL*i)%mod)%mod-p)%mod+mod)%mod;\n            p = (p+nums[i])%mod;\n        }\n        return (ans+mod)%mod;\n    }\n};\n```
['Sorting', 'Prefix Sum', 'C++']