Easy with sets
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

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

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

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

# Code
```typescript []
function distinctDifferenceArray(nums: number[]): number[] {
    const res = new Array(nums.length).fill(0);
    
    for (let i = 0; i < nums.length; i++) {
        // Compute prefix set
        const prefixSet = new Set(nums.slice(0, i + 1));
        
        // Compute suffix set
        const suffixSet = new Set(nums.slice(i + 1));
        
        // Calculate the difference
        res[i] = prefixSet.size - suffixSet.size;
    }
    
    return res;
}

```
['TypeScript']