✅ One Line Solution
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1.1 - One Line\nTime complexity: O(n*log
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1.1 - One Line\nTime complexity: $$O(n*log(n))$$. Space complexity: $$O(n)$$.\n```python3\nclass Solution:\n    def sumDistance(self, a: List[int], s: str, d: int) -> int:\n        return sum(accumulate(range(1,len(b:=sorted(x+d*((q>\'L\')*2-1) for x,q in zip(a,s)))),lambda p,i:p+(b[i]-b[i-1])*i,initial=0))%(10**9+7)\n```\n\n# Code #1.2 - Unwrapped\n```python3\nclass Solution:\n    def sumDistance(self, a: List[int], s: str, d: int) -> int:\n        b = sorted(x + d*((q == \'R\')*2 - 1) for x,q in zip(a, s))\n        res = sum(accumulate(range(1, len(b)), lambda p, i: p + (b[i] - b[i-1])*i, initial=0))\n\n        return res%(10**9 + 7)\n```\n\n(Disclaimer 2: code above is just a product of fantasy packed into one line, it is not claimed to be \'true\' oneliners - please, remind about drawbacks only if you know how to make it better)
['Array', 'Brainteaser', 'Sorting', 'Prefix Sum', 'Python', 'Python3']