c++(1ms) hash tables
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
  vector<int> distinctDifferenceArray(vector<int>& nums) {
    int l[51] = {0}, r[51] = {0};
    vector<int> ans(nums.size()), t(nums.size());

    for(int i = 0, k = 0; i != nums.size(); ++i){
      if(++l[nums[i]] == 1) ++k;
      t[i] = k; 
    }

    for(int i = nums.size()-1, k = 0; i >= 0; --i){
      ans[i] = t[i] - k;
      if(++r[nums[i]] == 1) ++k;
    }

    return ans;      
  }
};
```
['C++']