Easy C++
Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space compl
# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> distinctDifferenceArray(vector<int>& nums) {\n        int n=nums.size();\n        vector<int> cnt1(n,0),cnt2(n,0);\n        vector<int> ans(n,0);\n        unordered_map<int,int> x,y;\n        for(int i=0;i<n;i++){\n            x[nums[i]]=1;\n            y[nums[n-i-1]]=1;\n            cnt1[i]=x.size();\n            cnt2[n-i-1]=y.size();\n        }\n        for(int i=0;i<n-1;i++){\n            ans[i]=cnt1[i]-cnt2[i+1];\n        }\n        ans[n-1]=cnt1[n-1];\n        return ans;\n    }\n};\n```
['Array', 'Hash Table', 'Counting', 'C++']