Accepted C++ solution || No Runtime Error
\n\n# Complexity\n- Time complexity: O(nlog(n))\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: o(n)\n Add your space complexity here, e.g. O
\n\n# Complexity\n- Time complexity: $$O(nlog(n))$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$o(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int MOD = 1000000007;\n    int sumDistance(vector<int>& nums, string s, int d) {\n        int n = nums.size();\n        vector<long long int> v(n,0);\n        for(int i = 0; i < n; i++) v[i]+=nums[i];\n        for(int i = 0; i < n; i++){\n            if(s[i] == \'R\') v[i] += d;\n            else v[i] -= d;\n        }\n        long long ans = 0;\n        long long pref = 0;\n        sort(v.begin(), v.end());\n        for(long long i = 0; i < n; i++){\n            ans += i * (long long) v[i] - pref;\n            ans %= MOD;\n            pref += v[i];\n        }\n        return ans;\n    }\n};\n```
['C++']