JavaScript Solution
Intuition\nWe can first simulate the movement of the robots according to the given directions. Then, we can calculate the distances between pairs of robots at e
# Intuition\nWe can first simulate the movement of the robots according to the given directions. Then, we can calculate the distances between pairs of robots at each time step and sum them up.\n\n# Approach\n1. Simulate the movement of the robots according to the given directions.\n2. For each time step, calculate the distances between pairs of robots.\n3. Sum up the distances between all pairs of robots at each time step.\n4. Return the total sum of distances modulo 10^9 + 7 \n\n# Complexity\n- Time complexity:\nO(n log n) due to sorting, where n is the number of robots.\n\n- Space complexity:\nO(n) for storing the modified positions of the robots.\n\n# Code\n```\nvar sumDistance = function(nums, s, d) {\n    let sum = 0;\n    let n = nums.length;\n    nums = nums.map((val, i) => (s[i] === "L" ? val - d : val + d));\n    nums.sort((a, b) => a - b);\n    \n    let prefixSum = Array(n).fill(0);\n    prefixSum[0] = nums[0];\n    \n    for (let i = 1; i < n; i++) {\n        prefixSum[i] = (prefixSum[i - 1] + nums[i]) % 1000000007;\n    }\n    \n    for (let i = 1; i < n; i++) {\n        sum = (sum + i * nums[i] - prefixSum[i - 1]) % 1000000007;\n    }\n    \n    return sum;\n};\n\n```
['JavaScript']