JAVA | EASY TO UNDERSTAND FOR BEGINNERS 🔥
Code\n\nclass Solution {\n    public int[] distinctDifferenceArray(int[] nums) {\n        int n = nums.length;\n        int[] res = new int[n];\n        for (in
# Code\n```\nclass Solution {\n    public int[] distinctDifferenceArray(int[] nums) {\n        int n = nums.length;\n        int[] res = new int[n];\n        for (int i = 0; i < n; i++) {\n            HashSet<Integer> hs = new HashSet<>();\n            for (int j = 0; j <= i; j++) {\n                hs.add(nums[j]);\n            }\n            HashSet<Integer> js = new HashSet<>();\n            for (int j = i + 1; j < n; j++) {\n                js.add(nums[j]);\n            }\n            res[i] = hs.size()-js.size();\n        }\n        return res;\n    }\n}\n```
['Ordered Map', 'Counting', 'Java']