Get Largest Number
Reported by candidates from Palantir's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Palantir's February OA included a problem asking you to construct the largest possible number from a list of integers by arranging them in a specific order. This is a sorting problem with a twist: you can't just sort numerically. The trick is figuring out the right comparator. If you blank on the exact logic during the live OA, StealthCoder will read the problem and hand you the pattern in seconds, so you can code with confidence instead of second-guessing your sort order.
Pattern and pitfall
The core insight is that you need a custom comparator, not standard numeric sort. For two numbers a and b, you compare the concatenated strings: if ab > ba as strings, then a should come before b. This greedy approach guarantees the lexicographically largest arrangement. The pitfall is overthinking it or trying to sort by digit count or magnitude. Once you nail the comparator logic, the implementation is straightforward: sort using your custom rule, concatenate, and return. When you're live and your brain freezes on comparator syntax, StealthCoder becomes your safety net, feeding you the exact pattern so you can move fast.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Get Largest Number cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as largest number. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Palantir's OA.
Palantir reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Get Largest Number FAQ
Is this just a standard sort problem?+
No. Standard numeric sort fails here. You need a custom comparator that compares concatenated string results. For example, 3 and 30: '330' vs '303', so 3 comes first. That's the trick.
What's the time complexity?+
O(n log n) for sorting, where n is the number of integers. The string concatenation inside the comparator adds a constant factor per comparison, but it doesn't change the overall complexity tier.
Edge case: what if all numbers are zero?+
Return '0', not '000...'. This is a common gotcha. After you build the concatenated result, check if the first character is '0' and return '0' if so.
Do I need to handle negative numbers?+
The problem typically uses non-negative integers. If negatives are included, they'd need separate handling. Check the problem statement carefully during the OA.
How do I prepare for this in 48 hours?+
Understand the custom comparator pattern. Practice writing the logic: if concatenating a+b vs b+a, which is lexicographically larger. That one insight is 90% of the solution.