Third Maximum Number

Easy
Arrays Array Sorting

Given an integer array, return the third distinct maximum. If fewer than 3 distinct, return the max.

Constraints

1 ≤ nums.length ≤ 10^4

Examples

Example 1:
Input: 3 2 1
Output: 1
Example 2:
Input: 1 2
Output: 2
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.