2670. Find the Distinct Difference Array
You are given a 0-indexed array
numsof lengthn.The distinct difference array of
numsis an arraydiffof lengthnsuch thatdiff[i]is equal to the number of distinct elements in the suffixnums[i + 1, ..., n - 1]subtracted from the number of distinct elements in the prefixnums[0, ..., i].Return the distinct difference array of
nums.Note that
nums[i, ..., j]denotes the subarray ofnumsstarting at indexiand ending at indexjinclusive. Particularly, ifi > jthennums[i, ..., j]denotes an empty subarray.
1 | class Solution { |