✔Easy Java Solution Using HashSet || But 18 ms😢
\n# Code\n\nclass Solution {\n    public int[] distinctDifferenceArray(int[] nums) {\n        int n=nums.length;\n        int[] d=new int[n];\n        for (int 
\n# Code\n```\nclass Solution {\n    public int[] distinctDifferenceArray(int[] nums) {\n        int n=nums.length;\n        int[] d=new int[n];\n        for (int i = 0; i < n; i++) {\n            Set<Integer> pre=new HashSet<>();\n            for (int j = 0; j <= i; j++) {\n                pre.add(nums[j]);\n            }\n            Set<Integer> suf=new HashSet<>();\n            for (int j = i + 1; j < n; j++) {\n                suf.add(nums[j]);\n            }\n            d[i]=pre.size()-suf.size();\n        }\n        return d;\n    }\n}\n```
['Dynamic Programming', 'Ordered Set', 'Java']