c++ | Ants on a Plank
\nclass Solution {\npublic:\n    int md=1e9+7;\n    int sumDistance(vector<int>& nums, string s, int d) {\n        for(int i=0;i<size(nums);++i){\n            i
```\nclass Solution {\npublic:\n    int md=1e9+7;\n    int sumDistance(vector<int>& nums, string s, int d) {\n        for(int i=0;i<size(nums);++i){\n            if(s[i]==\'R\')nums[i]+=d;\n            else nums[i]-=d;\n        }\n        sort(begin(nums),end(nums));\n        long pf=0,ans=0;\n        for(int i=0;i<size(nums);++i){\n            ans+=(long)nums[i]*i-pf;\n            pf+=nums[i];\n            ans%=md; \n        }\n        return ans;\n    }\n};\n```
['C', 'Prefix Sum']