C++ || MAP || 100% FASTER
FIRST I STORE COUNT OF EACH ELEMENT IN AN UNORDERED_MAP(mp2) WORK AS SUFFIX DISTICNT NO.\nUSE ANOTHER UNORDERED_MAP(mp1) MAINTAIN DISTINCT COUNT OF PREFIX ELEME
FIRST I STORE COUNT OF EACH ELEMENT IN AN UNORDERED_MAP(mp2) WORK AS SUFFIX DISTICNT NO.\nUSE ANOTHER UNORDERED_MAP(mp1) MAINTAIN DISTINCT COUNT OF PREFIX ELEMENTS.\nPUSH (prefix.distint_no - suffix.distint_no) into answer array\n\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> distinctDifferenceArray(vector<int>& nums) {\n        unordered_map<int,int> mp1,mp2;\n        for(auto &i: nums)mp2[i]++;\n        vector<int> ans;\n        for(auto &i: nums){\n            mp2[i]--;\n            mp1[i]++;\n            if(mp2[i]==0)mp2.erase(i);\n            ans.push_back(mp1.size()-mp2.size());\n        }\n        return ans;\n    }\n};\n```
['Hash Table', 'Hash Function', 'C++']