Simple java solution
Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\n\n# Code\n\nclass Solution {\n    public int[] distinctDifferenceArray(int[] nums) {\n        i
# Complexity\n- Time complexity: $$O(n)$$\n\n- Space complexity: $$O(1)$$\n\n# Code\n```\nclass Solution {\n    public int[] distinctDifferenceArray(int[] nums) {\n        int a[]=new int[51];\n        int len=nums.length;\n        int res[]=new int[len];\n        for(int i:nums)\n        {\n            a[i]++;\n        }\n        int b[]=new int[51];\n        for(int i=0;i<len;i++)\n        {\n            b[nums[i]]++;\n            a[nums[i]]--;\n            int count=0,count1=0;\n            for(int j=1;j<=50;j++)\n            {\n                if(a[j]>0)\n                {\n                    count++;\n                }\n            }\n            for(int j=1;j<=50;j++)\n            {\n                if(b[j]>0)\n                {\n                    count1++;\n                }\n            }\n            res[i]=count1-count;\n        }\n        return res;\n    }\n}\n```
['Java']