2670. Find the Distinct Difference Array
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
```kotlin []
class Solution {
    fun distinctDifferenceArray(nums: IntArray): IntArray {
        /*
            myObservation
            1. We have to select the index and treat it as prefix(also distinct) and all the right side as suffix which should be distinct.
            2. Then find the distinct list of prefix - distinct list of suffix = store in array
            3. return the stored value in array.

            NOTE- remember the edge cases when storing for the last index in array

        */

        var prefixHset = HashSet<Int>()
        var arr = IntArray(nums.size)
        var index = 0
        var extra = 101
        for (i in 0 until nums.size)
        {
            var suffixHset = HashSet<Int>()
            prefixHset.add(nums[i]) // it will also have last element
            for(j in i+1 until nums.size)
            {
                suffixHset.add(nums[j])
            }
            //println("prefix haset is = ${prefixHset.size}")
            //println("suffix haset is = ${suffixHset.size} | suffixHser is = ${suffixHset}")

            arr[index] = prefixHset.size - suffixHset.size
            index++
            //println(arr.contentToString())
        }
        return arr
    }
}
```
['Kotlin']