[JAVA] easy solution using Set
Complexity\n- Time complexity: O(N * N)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(N)\n Add your space complexity here, e.g. O(n) \n\n
# Complexity\n- Time complexity: O(N * N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int[] distinctDifferenceArray(int[] nums) {\n        int n = nums.length;\n        int ans[] = new int[n];\n        Set<Integer> prefix = new HashSet<>();\n        for(int i = 0; i < n; i ++) {\n            prefix.add(nums[i]);\n\n            Set<Integer> suffix = new HashSet<>();\n            for(int j = i + 1; j < n; j ++)\n               suffix.add(nums[j]);\n\n            ans[i] = prefix.size() - suffix.size();\n        }\n        return ans;\n    }\n}\n```\n# PLEASE UPVOTE IF IT WAS HELPFULL
['Array', 'Hash Table', 'Java']