[Python 3] Let the robots pass thru each other
Intuition\nIgnore collisions and let the robots go through each other, the net effect is the same. Calculate their final positions, and use a rolling sum to get
# Intuition\nIgnore collisions and let the robots go through each other, the net effect is the same. Calculate their final positions, and use a rolling sum to get the answer.\n\n# Code\n```\nclass Solution:\n    def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n        n = len(nums)\n        for i in range(n):\n            if s[i] == \'L\':\n                nums[i] -= d\n            else:\n                nums[i] += d\n                \n        nums.sort()\n        d = [0]\n        for i in range(1, n):\n            d.append(nums[i] - nums[0])\n        MOD = 1_000_000_007\n        s = sum(d) % MOD\n        \n        ans = s\n        for i in range(1, n):\n            s = (s - (n - i) * (nums[i] - nums[i - 1])) % MOD\n            ans = (ans + s) % MOD\n        return ans\n```
['Python3']