C++: move d units and sort, ignoring collision
when 2 robots collide, it switches direction. but for the purpose of finding the pair wisee distance, it is equivalent to switching robots and keep the same dir
- when 2 robots `collide`, it `switches direction`. but for the purpose of finding the pair wisee distance, it is equivalent to `switching robots` and `keep the same direction`.\n- `sort` the final postion array\n- `prefix sum` to find the answer.\n```\nclass Solution {\npublic:\n    int sumDistance(vector<int>& nums, string s, int d) {\n        int sz = s.size(), sum = 0, mod = 1\'000\'000\'007;\n        \n        vector<long long> pos;\n        for(int i = 0; i < sz; ++i)\n            pos.push_back(nums[i] + (s[i] == \'L\' ? -d : d));\n        \n        sort(pos.begin(), pos.end());\n        \n        for(int i = 0, psum = 0; i < sz; ++i) {\n            sum = (sum + (long long)i * pos[i] - psum) % mod;\n            psum = (psum + pos[i]) % mod;\n        }\n        return (sum + mod) % mod;\n    }\n};\n```
['C++']