Python || Hash Map
Code\n\nclass Solution:\n    def distinctDifferenceArray(self, nums: List[int]) -> List[int]:\n        pre={nums[0]:1}\n        suf={}\n        res=[]\n        
# Code\n```\nclass Solution:\n    def distinctDifferenceArray(self, nums: List[int]) -> List[int]:\n        pre={nums[0]:1}\n        suf={}\n        res=[]\n        for j in range(1,len(nums)):\n            if nums[j] in suf:\n                suf[nums[j]]+=1\n            else:\n                suf[nums[j]]=1\n        for i in range(len(nums)-1):\n            res.append(len(pre)-len(suf))\n            if nums[i+1] in pre:\n                pre[nums[i+1]]+=1\n            else:\n                pre[nums[i+1]]=1\n            suf[nums[i+1]]-=1\n            if suf[nums[i+1]]==0:\n                suf.pop(nums[i+1])\n        res.append(len(pre)-len(suf))\n        return res\n```
['Python3']