simple set solution || c++ || easy to understand using pre count and post count
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\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         int i = 0;  \n         vector<int> ans;\n\n         while(i<n){\n             int postcount = 0;\n             int precount = 0;\n             set<int> count;\n             for(int j=i+1;j<n;j++){\n                 count.insert(nums[j]);\n             }\n             postcount = count.size();\n             count.clear();\n            \n             for(int j=0;j<=i;j++){\n                 count.insert(nums[j]);\n             }\n             precount = count.size();\n             count.clear();\n\n             ans.push_back((precount - postcount));\n             i++;\n\n         }\n\n         return ans;\n     }\n\n```
['C++']