ans to 0 to store the final result.i of the subarray from 0 to the size of nums.i, initialize an empty hash map ump to store the frequency of elements.j of the subarray from i to the size of nums.nums[j] in ump.nums[j] is 1, increment the distinct count count.count to ans.ans as the final result.