Go || Use Two Map
Complexity\n- Time complexity: O(2n)\n- Space complexity: O(n)\n\n# Code\n\nfunc distinctDifferenceArray(nums []int) []int {\n\tn := len(nums)\n\tres := make([]
# Complexity\n- Time complexity: $$O(2n)$$\n- Space complexity: $$O(n)$$\n\n# Code\n```\nfunc distinctDifferenceArray(nums []int) []int {\n\tn := len(nums)\n\tres := make([]int, n)\n\tm1, m2 := make(map[int]int), make(map[int]int)\n\tfor i := 0; i < n; i++ {\n\t\tm2[nums[i]]++\n\t}\n\n\tfor i := 0; i < n; i++ {\n\t\tm1[nums[i]]++\n\t\tm2[nums[i]]--\n\t\tif m2[nums[i]] == 0 {\n\t\t\tdelete(m2, nums[i])\n\t\t}\n\t\tres[i] = len(m1) - len(m2)\n\t}\n\treturn res\n}\n```
['Go']