You are given an integer array nums.
Your task is to find the third distinct maximum number in the array.
If there are fewer than three distinct numbers, return the highest number instead.
In other words:
• You must consider only unique numbers (ignore duplicates).
• If the third largest unique number exists, return it.
• Otherwise, return the largest number in the array.
Input: nums = [10, 5, 7, 10, 2]
Output: 5
Input: nums = [4, 4, 4]
Output: 4
Accepted:
Submission: