Largest Number
Reported by candidates from LinkedIn's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The all-zeros case is what kills most first attempts at this one. LinkedIn candidates reported Largest Number in September 2026, and the trap is simple: sort the numbers wrong and you get "9534303", or sort them right and return "000" when the answer should be "0". The real question is how you order the numbers, and plain numeric or string order won't do it. It's a custom sort on concatenation. If your head goes blank mid-assessment, StealthCoder runs invisibly on your screen as a safety net, but you can own this pattern before then.
The problem
Given an array of nonnegative integers nums, arrange them so that their decimal representations form the largest possible number. Return the result as a string. If every number is zero, return "0". Function largestNumber(nums: int[]) → String Examples Example 1 nums = [10,2] return = "210" Placing 2 before 10 produces the larger concatenation. Example 2 nums = [3,30,34,5,9] return = "9534330" Ordering by pairwise concatenation places 9, 5, 34, 3, then 30. Constraints 1 <= nums.length <= 100 0 <= nums[i] <= 1000000000
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is a custom comparator. For two numbers a and b as strings, put a before b if a+b is greater than b+a. Example 2 shows why: 3 and 30 compare as "330" versus "303", so 3 goes first. Convert every number to a string, sort with that comparator, then join. Plain lexicographic sort fails because "30" beats "3" when it shouldn't. Plain numeric sort fails for the same reason. The pitfall is the edge case: if the first string after sorting is "0", every number was zero, so return "0" instead of a run of zeros. With at most 100 numbers, sorting costs O(n log n) comparisons on short strings, which is trivial. In Python, use functools.cmp_to_key. In Java, pass a lambda to Arrays.sort on a String array. If you blank on the comparator during the live OA, StealthCoder can hand you the working version, but the logic fits in six lines.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill 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. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.
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 LinkedIn's OA.
LinkedIn reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Largest Number FAQ
How hard is Largest Number really?+
Medium. The code is short, but the idea of sorting by concatenation isn't obvious if you haven't seen it. Once you know the comparator, it's about ten lines. Most failures come from the leading zero edge case, not the sort itself.
What's the trick to the sort order?+
Compare a+b against b+a as strings. If a+b is bigger, a goes first. This pairwise rule is consistent and transitive, so it produces a valid sort. Example: 3 and 30 give "330" versus "303", so 3 comes before 30.
Why does my solution return "000" on all zeros?+
After sorting and joining, you have to check the result. If the first character is "0", the largest value is zero, so return "0". Checking the first element of the sorted list works too, since the biggest string being "0" means all are zeros.
Do I need to worry about overflow with values up to 1000000000?+
No, if you work with strings. The concatenated result can have up to 1000 digits, which no integer type holds. Convert to strings first, compare as strings, and join. Never parse the final answer back into a number.
How do I prepare for this in 48 hours?+
Write it once from memory in your language. Learn how to make a custom comparator there, like cmp_to_key in Python. Then test [0,0], [10,2], and [3,30,34,5,9]. That covers the edge case and both examples from the LinkedIn report.