Easy · Arrays & Strings · about 10 minutes
Asked at Google, Amazon, Bloomberg, NVIDIA, Meta, Waymo, Anduril, xAI, Mistral AI.
Return the third distinct maximum of nums; if it doesn't exist, return the maximum. Aim for O(n).
nums