Python 3   ||   2 lines,  w/ notes and example   ||   T/S: 99% / 97%
Notes:\n- The problem could be rewritten as: "Each robot travelsdunits left or right based on whether its corresponding element insis LorR, respectively. Find t
Notes:\n- The problem could be rewritten as: "Each robot travels`d`units left or right based on whether its corresponding element in`s`is `L`or`R`, respectively. Find the sum of the distances based on these final positions."\n\n- The function`(ord(ch)-79)//3 * d`maps`\'L\'`-->`-d` and`\'R\'`-->`d`\n\n- It is left to the curious and algebraically capable reader to justify why, in the example, the inner product of `[-7,-2,3,6]`and`[-3,-1,1,3]`gives us the correct answer.\n\n```\nclass Solution:\n    def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n\n        nums = sorted([num+(ord(ch)-79)//3*d            # Example : nums: [1,0,4,-5],  s:  \'RLRL\',  d:  2\n                       for num, ch in zip(nums,s)])    \n                                                        #  nums = sorted([1+2, 0-2, 4+2, -5-2])\n                                                        #       = [-7,-2,3,6]\n\n        return sum(map(mul, nums, range(1-len(nums),    #  sum(map(mul, [[-7,-2,3,6],[-3,-1,1,3]]))\n                       len(nums), 2)))%1000000007       #  sum((-7*-3)+(-2*-1)+(3*1)+(6*3))\n                                                        #  return 44\n\n```\n[https://leetcode.com/problems/movement-of-robots/submissions/1292983083/](https://leetcode.com/problems/movement-of-robots/submissions/1292983083/)\n\n\nI could be wrong, but I think that time complexity is *O*(*N*log*N*) (because of the`sort`) and space complexity is *O*(*N*), in which *N* ~`len(nums)`.
['Python3']