🔥Java Solution || Easy to Understand
Complexity\n- Time complexity: O(N^2)\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^2)\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[] arr = new int[nums.length];\n        int index = 0;\n        Set<Integer> set = new HashSet<>();\n        for(int i = 0; i < nums.length; i++) {\n            int left = 0;\n            int right = 0;\n            for(int j = 0; j <= i; j++) {\n                set.add(nums[j]);\n            }\n            left = set.size();\n            set.clear();\n            \n            for(int k = i+1; k < nums.length; k++) {\n                set.add(nums[k]);\n            }\n            right = set.size();\n            set.clear();\n            arr[index++] = left - right; \n        }\n        return arr;\n    }\n}\n```
['Java']