prefixSet to keep track of distinct elements in the prefix.prefixCounts to store the count of distinct elements in the prefix up to each index.nums from left to right.
prefixSet.prefixSet to prefixCounts.suffixSet to keep track of distinct elements in the suffix.diff to store the final distinct difference array.nums from right to left.
suffixSet.prefixSet minus the size of suffixSet.diff list.diff list.