distinctDifferenceArray: easy O(n) solution. ✅
IntuitionThe aim is to compute an array where each element represents the difference between the number of unique elements in the prefix and suffix of the given
# Intuition
The aim is to compute an array where each element represents the difference between the number of unique elements in the prefix and suffix of the given array nums.

# Approach
1. Use an array occ to count the occurrences of each number in nums.
2. Iterate through nums to populate the occ array and count the total number of unique elements.
3. Allocate memory for the result array diff and set returnSize to numsSize.
4. Use a boolean array prefix to keep track of unique elements in the prefix of nums.
5. Iterate through nums, updating prefix and occ arrays to count unique elements in the prefix and suffix, respectively.
6. Compute the difference between the number of unique elements in the prefix and suffix for each index, and store it in the diff array.
7. Return the diff array.

# Complexity
- Time complexity:
O(n)

- Space complexity:
O(max(nums))

# Code
```c []
/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
int* distinctDifferenceArray(int* nums, int numsSize, int* returnSize) {
    int occ[51]={};
    int uniques=0;
    for(int i=0;i<numsSize;i++){
        occ[nums[i]]++;
        if(occ[nums[i]]==1) uniques++;
    }
    int *diff=malloc(sizeof(int)*numsSize);
    *returnSize=numsSize; 
    int uniques_prefix=0;
    bool prefix[51]={};
    for(int i=0;i<numsSize;i++){
        if(!prefix[nums[i]]){
            prefix[nums[i]]=true;
            uniques_prefix++; 
        }
        occ[nums[i]]--;
        if(occ[nums[i]]==0) uniques--;
        diff[i]=uniques_prefix-uniques;
    }
    return diff;
}
```
['Array', 'Hash Table', 'C']