C++ | Tricky yet VV Easy question | O(nlogn)
Approach\n Describe your approach to solving the problem. \nWe see the robots coliding and moving to its own position again, yet we can observe even if the coli
# Approach\n<!-- Describe your approach to solving the problem. -->\nWe see the robots coliding and moving to its own position again, yet we can observe even if the colision never happened the robots would be found in those places anyhow. As we are not concerned about any specific robots we can consider all as one and consider the same robot kept on moving int he same direction. And to find the difference we used prefix sum method. As for:a,b,c,d Difference of d with all 3 is 3*d-(a+b+c).\n\n\n# Code\n```\nint M = 1000000007;\nclass Solution {\npublic:\n    int sumDistance(vector<int>& nums, string s, int d) {\n        for(int i=0;i<nums.size();i++){\n            if(s[i]==\'R\')nums[i]+=d;\n            else nums[i]-=d;\n        }\n        long pre=0,sum=0;\n        sort(nums.begin(),nums.end());\n        for(int i=0;i<nums.size();i++){\n            sum=(sum+i*(long)nums[i]-pre)%M;\n            pre+=(nums[i]%M);\n        }\n        return (int)sum;\n    }\n};\n\n```
['C++']