Two pass Easy Solution
IntuitionTwo passes:
First pass(left to right): calculate the number of distinct numbers to the left of i
Second pass(right to left): calculate the number of di
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Two passes:
First pass(left to right): calculate the number of distinct numbers to the left of i
Second pass(right to left): calculate the number of distinct numbers to the right of i. Update answer array by len(left) - len(right)

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity: O(n)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def distinctDifferenceArray(self, nums: List[int]) -> List[int]:
        # ans = []
        # prefix, postfix = 1, 0
        # for i in range(len(nums)):
        #     prefix = len(Counter(nums[:i+1])) 
        #     postfix = len(Counter(nums[i+1:]))
        #     ans.append(prefix - postfix)
        # return ans

        ans = [0] * len(nums)
        seen = set()
        for i in range(len(nums)):
            seen.add(nums[i])
            ans[i] = len(seen)  

        remaining = set()
        for i in range(len(nums)-1, -1, -1):
            temp = len(remaining) 
            remaining.add(nums[i])    
            ans[i] = ans[i] - temp
        return ans
```
['Python3']