C++ || using Set
\nclass Solution {\npublic:\n    vector<int> distinctDifferenceArray(vector<int>& nums) {\n        unordered_set<int> st;\n        vector<int> pre;\n        for
```\nclass Solution {\npublic:\n    vector<int> distinctDifferenceArray(vector<int>& nums) {\n        unordered_set<int> st;\n        vector<int> pre;\n        for(auto i : nums){\n            st.insert(i);\n            pre.push_back(st.size());\n        }\n        st.clear();\n        vector<int> suff;\n        suff.push_back(0);\n        for(int i=nums.size()-1;i>=0;i--){\n            st.insert(nums[i]);\n            suff.push_back(st.size());\n        }\n        reverse(suff.begin(),suff.end());\n        vector<int> ans;\n        for(int i=0;i<nums.size();i++){\n            ans.push_back(pre[i]-suff[i+1]);\n        }\n        return ans;\n    }\n};\n```
['C', 'Ordered Set', 'C++']