C++ || Maps || Easy approach
Here is my c++ code for this problem.\n\n# Complexity\n- Time complexity:O(n)\n\n- Space complexity:O(n)\n\n# Code\n\nclass Solution {\npublic:\n    vector<int>
Here is my c++ code for this problem.\n\n# Complexity\n- Time complexity:$$O(n)$$\n\n- Space complexity:$$O(n)$$\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> distinctDifferenceArray(vector<int>& nums) {\n        map<int, int>m1, m2;\n        vector<int>ans;\n        for(int i=0; i<nums.size(); i++){m1[nums[i]]++;}\n        for(int i=0; i<nums.size(); i++){\n            m2[nums[i]]++;\n            m1[nums[i]]--;\n            if(m1[nums[i]]==0){\n                m1.erase(nums[i]);\n            }\n            ans.push_back(m2.size()-m1.size());\n        }\n        return ans;\n    }\n};\n```
['C++']