Search⌘ K
AI Features

Third Maximum Number

Explore methods to find the third distinct maximum element in an integer array. Understand problem constraints, analyze examples, and implement solutions to handle arrays with fewer than three distinct numbers effectively.

Statement

Given an integer array, nums, determine and return the third distinct maximum element in the array. If the array contains fewer than three distinct elements, return the maximum element instead.

Constraints:

  • 1<=1 <= nums.length ...