C++ || Hashing ✔✔
Complexity\n- Time complexity: O(nlogn)\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
# Complexity\n- Time complexity: $$O(nlogn)$$\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        map<int,int> pref,suff;\n        int n= nums.size();\n        vector<int> ans;\n        for (int i=0; i<n; i++)suff[nums[i]]++;\n        for (int i=0; i<n; i++){\n            suff[nums[i]]--;\n            pref[nums[i]]++;\n            if (suff[nums[i]]==0)suff.erase(nums[i]);\n            ans.push_back(pref.size()-suff.size());\n        }\n        return ans;\n    }\n};\n```
['Array', 'Hash Table', 'Ordered Map', 'Counting', 'C++']