Python 3   ||   7 lines, no sets,  w/ example   ||   T/S: 76% / 89%.
\nclass Solution:\n    def distinctDifferenceArray(self, nums: List[int]) -> List[int]:    #  Example:   nums = [3,2,3,4,2]\n                                   
```\nclass Solution:\n    def distinctDifferenceArray(self, nums: List[int]) -> List[int]:    #  Example:   nums = [3,2,3,4,2]\n                                                                        #  \n        pref, suff = defaultdict(int), Counter(nums)                    #   pref, suff = {}, {2:2, 3:2, 4:1}\n\n        cur = -len(suff)                                                #  cur = -3\n\n        for i, n in enumerate(nums):                                    #  n  cur  pref           suff           nums\n            pref[n]+= 1                                                 # \u2013\u2013\u2013 \u2013\u2013\u2013  \u2013\u2013\u2013\u2013\u2013\u2013\u2013\u2013       \u2013\u2013\u2013\u2013\u2013\u2013\u2013        \u2013\u2013\u2013\u2013\u2013\u2013\u2013\n            suff[n]-= 1                                                 #      -3  {2:0,3:0,4:0}  {2:2,3:2,4:1}  [| 3, 2, 3, 4, 2]\n            cur = nums[i] = cur + (pref[n] == 1) + (suff[n] == 0)       #  3   -2  {2:0,3:1,4:0}  {2:2,3:1,4:1}  [-2,| 2, 3, 4, 2]\n                                                                        #  2   -1  {2:1,3:1,4:0}  {2:1,3:1,4:1}  [-2,-1,| 3, 4, 2]\n        return  nums                                                    #  3    0  {2:1,3:2,4:0}  {2:1,3:0,4:1}  [-2,-1, 0,| 4, 2]\n                                                                        #  4    2  {2:1,3:2,4:1}  {2:1,3:0,4:0}  [-2,-1, 0, 2,| 2]\n                                                                        #  2    3  {2:2,3:2,4:1}  {2:0,3:0,4:0}  [-2,-1, 0, 2, 3|]\n```\n[https://leetcode.com/problems/find-the-distinct-difference-array/submissions/946122293/](https://leetcode.com/problems/find-the-distinct-difference-array/submissions/946122293/)\n\nI could be wrong, but I think that time complexity is *O*(*N*) and space complexity is *O*(*N*), in which *N* ~ `len(nums)`.\n
['Python3']