Using Set | | C++ 😍 😎
Code

# Code
```cpp []
class Solution {
public:
    vector<int> distinctDifferenceArray(vector<int>& nums) {
        unordered_set<int> Distinct;
        vector<int> diff(nums.size());

        for (int i = 0; i < nums.size(); ++i) {
            // suffix
            for (int j = i + 1; j < nums.size(); ++j) {
                Distinct.insert(nums[j]);
            }

            int x = Distinct.size();
            Distinct.clear();

            // prefix
            for (int j = 0; j <= i; ++j) {
                Distinct.insert(nums[j]);
            }

            int y = Distinct.size();
            Distinct.clear();

            diff[i] = y - x;
        }

        return diff;
    }
};
```
['Array', 'Ordered Set', 'C++']