Third Maximum Number
A easy-tier problem at 37% community acceptance, tagged with Array, Sorting. Reported in interviews at Goldman Sachs and 0 others.
Third Maximum Number is a deceptive problem. It's marked easy, but the acceptance rate sits at 37%, which means most candidates either overthink it or miss the edge case that flips the problem. Goldman Sachs has asked this. The trap isn't the algorithm, it's the rule about what to return when there's no third distinct maximum. If you blank on that detail during your live OA, StealthCoder surfaces the solution invisibly while you're screen-sharing.
Companies that ask "Third Maximum Number"
Third Maximum Number is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.
Get StealthCoderThe obvious path is to sort and pick the third element. That works until the problem tells you to return the maximum if there aren't three distinct numbers. Then sorting alone isn't enough. You need to track the top three distinct values as you iterate, handle duplicates correctly, and know when to fall back. Most candidates either filter duplicates first then sort (wasteful), or they scan the array three times looking for max, second max, third max (brittle). The efficient approach uses a set to enforce uniqueness, then finds the third largest in one pass. Common failure: forgetting that input can have fewer than three distinct values, so you must validate before returning the third. If this problem hits your assessment and you stall on the fallback logic, StealthCoder runs in real time and shows the working solution.
Pattern tags
You know the problem.
Make sure you actually pass it.
Third Maximum Number recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Third Maximum Number interview FAQ
Why is acceptance rate so low for an easy problem?+
The edge case. Candidates sort or use heap thinking they're done, then fail on inputs with fewer than three distinct numbers. The rule to return the maximum in that case isn't obvious from the problem title. It punishes candidates who don't read carefully and test boundary inputs first.
What's the trick that separates AC from WA?+
Handle duplicates and validate before returning. Use a set to track distinct values, not raw array elements. Then check if you actually have three distinct numbers before accessing the third. If you skip that check, you'll get runtime error or wrong answer on test cases with duplicates.
Should I sort or iterate?+
Sorting is slower and masks the real problem. One-pass iteration with three variables to track the top three distinct values is cleaner. You avoid storing duplicates and keep space O(1). Sorting works but signals you didn't see the pattern, and it wastes time on the OA.
Is Goldman Sachs still asking this?+
It's reported at Goldman Sachs. Level easy problems cycle through interviews, especially in early rounds. You won't see it in every loop, but it's common enough that you should know it. The edge case logic it teaches transfers to harder array problems.
How does this relate to sorting and arrays?+
It's a topic tag validator. Sorting is the brute approach, but the problem teaches why iteration with state (tracking max, second, third) is faster. Arrays don't need sorting for this. It's a lesson in not defaulting to sort when selection or tracking works better.
Want the actual problem statement? View "Third Maximum Number" on LeetCode →