JAVA SOLUTION || ARRAY MANIPULATION || USING BOOLEAN FLAG ARRAY
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\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 {\n    public int[] distinctDifferenceArray(int[] nums) {\n\n        int prefix = 0;\n        int result[] = new int[nums.length];\n\n        boolean flag[] = new boolean[51];\n        for(int i = 0; i < nums.length; i++){\n\n            prefix = 0;\n\n            for(int j = 0; j <= i; j++){\n                if(!flag[nums[j]]){\n                    prefix++;\n                    flag[nums[j]] = true;\n                }\n            }\n\n            Arrays.fill(flag, false);\n\n            for(int j = i + 1; j < nums.length; j++){\n                if(!flag[nums[j]]){\n                    prefix--;\n                    flag[nums[j]] = true;\n                }\n            }\n\n            Arrays.fill(flag, false);\n\n            result[i] = prefix;\n        }\n\n        return result;\n    }\n}\n```
['Java']