Brute Force approach
Intuition\n Describe your first thoughts on how to solve this problem. \nMaintaing the prefix and suffix count\n# Approach\n Describe your approach to solving t
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nMaintaing the prefix and suffix count\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        vector<int> diff(n);\n\n    for (int i = 0; i < n; i++) {\n        unordered_set<int> prefix, suffix;\n        int prefix_size = 0, suffix_size = 0;\n\n        // Compute the size of the prefix set\n        for (int j = 0; j <= i; j++) {\n            if (!prefix.count(nums[j])) {\n                prefix.insert(nums[j]);\n                prefix_size++;\n            }\n        }\n\n        // Compute the size of the suffix set\n        for (int j = i + 1; j < n; j++) {\n            if (!suffix.count(nums[j])) {\n                suffix.insert(nums[j]);\n                suffix_size++;\n            }\n        }\n        diff[i] = prefix_size - suffix_size;\n\n    }\n\n     return diff;\n    }\n};\n```
['C++']