Given an array of integers nums, write a function to count the occurrences of each distinct element and return a dictionary where the keys are the distinct elements and the values are their respective counts.
Example 1:
Input: nums = [1, 2, 2, 3, 3, 3]
Output: {1: 1, 2: 2, 3: 3}
Example 2:
Input: nums = [4, 4, 5, 6, 6, 6, 7]
Output: {4: 2, 5: 1, 6: 3, 7: 1}
0 <= nums.length <= 10^5-10^9 <= nums[i] <= 10^9nums = [1, 2, 2, 3, 3, 3]Output{1: 1, 2: 2, 3: 3}WhyThe number 1 appears once, 2 appears twice, and 3 appears three times.nums = [4, 4, 5, 6, 6, 6, 7]Output{4: 2, 5: 1, 6: 3, 7: 1}WhyThe number 4 appears twice, 5 appears once, 6 appears three times, and 7 appears once.0 <= nums.length <= 10^5-10^9 <= nums[i] <= 10^9def count_distinct_elements(nums: list[int]) -> dict[int, int]: