Easy to understand || SET
\nclass Solution {\npublic:\n    vector<int> distinctDifferenceArray(vector<int>& nums) \n    {\n        int n = nums.size();\n        vector<int>ans(n, 0);\n  
```\nclass Solution {\npublic:\n    vector<int> distinctDifferenceArray(vector<int>& nums) \n    {\n        int n = nums.size();\n        vector<int>ans(n, 0);\n        //==========================================================\n        set<int>suffixSet;\n        vector<int>suffix(n, 0); \n        for (int i = n - 1; i >= 0; i--)\n        {\n            suffixSet.insert(nums[i]);\n            suffix[i] = suffixSet.size();\n        }\n        //=========================================================\n        set<int>prefixSet;\n        for (int i = 0; i < n; i++)\n        {\n            prefixSet.insert(nums[i]);\n            int prefixDistinct  = prefixSet.size();\n            int suffixDistinct = (i + 1 >= n)? 0 : suffix[i + 1];\n            ans[i] = prefixDistinct - suffixDistinct;\n        }\n        //===========================================================\n        return ans;\n    }\n};\n```
['C', 'Ordered Set', 'C++']