Search⌘ K
AI Features

Third Maximum Number

Explore how to determine the third distinct maximum number in an array or return the highest number when less than three distinct values are present. This lesson helps you apply problem-solving techniques for top K element challenges and implement your solution effectively in JavaScript.

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 ...