Brute force || Simple ||
\n\n# Approach\nBrute Force using Sets \nCheck size of pre stack and post stack for each index of nums.\n# Code\n\nclass Solution {\npublic:\n    vector<int> di
\n\n# Approach\nBrute Force using Sets \nCheck size of pre stack and post stack for each index of nums.\n# Code\n```\nclass Solution {\npublic:\n    vector<int> distinctDifferenceArray(vector<int>& nums) {\n        int n=nums.size();\n        vector<int>ans(n);\n        set<int>preSet;\n        set<int>postSet;\n        \n        for(int i=0;i<n;i++){\n            preSet.clear();\n            postSet.clear();\n            for(int j=0;j<=i;j++){\n               preSet.insert(nums[j]);\n            }\n            for(int k=i+1;k<n;k++){\n                postSet.insert(nums[k]);\n            }\n             ans[i]=preSet.size()-postSet.size();\n        }\n        return ans;\n    }\n};\n```\nPlease Upvote.
['Ordered Set', 'C++']