Reported September 2024
Googlesorting

Find Largest Number

Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Google OA. Under 2s to a working solution.
Founder's read

Google's "Find Largest Number" problem came up in September 2024 OAs, and candidates often blank on the comparison logic. The trap isn't algorithmic complexity; it's how you sort numbers to maximize the result. You're building the largest possible number by concatenating integers in a specific order. StealthCoder can feed you the comparison function if you freeze mid-interview, so you're never stuck guessing whether to compare a+b or b+a.

Pattern and pitfall

The core pattern is sorting with a custom comparator. You can't just sort numerically because 9 and 90 should be ordered as [9, 90], not [90, 9], to form 990. The key insight: compare two numbers by treating them as strings and checking which concatenation is larger (a+b vs b+a). Convert your input integers to strings, sort using this custom logic, concatenate the result, then handle the edge case where all numbers are zero and you should return '0', not '000'. Most candidates miss the zero-prefix trap. StealthCoder will surface the exact comparator pattern so you don't waste time re-deriving it under pressure.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Find 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 for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as largest number. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Google's OA.

Google reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find Largest Number FAQ

Is this really just a sorting problem?+

Yes, but with a non-standard comparator. You're not sorting by numeric value; you're sorting by which concatenation order produces a larger result. That's the whole trick. Once you nail the comparator, implementation is five lines.

What's the edge case everyone misses?+

When all input numbers are zero. Sorting [0, 0, 0] with the standard comparator gives '000', but the answer should be '0'. Check if the first character of your result is '0' and return '0' immediately.

Do I need to handle negative numbers or floats?+

The problem typically assumes non-negative integers. If the input includes negatives or decimals, it would be stated explicitly. Focus on the standard version unless told otherwise.

How do I verify my comparator is correct?+

Test with [3, 30, 34, 5, 9]. The answer should be '9534330'. If you get anything else, your comparator is backwards. Swap the comparison order if needed.

Can I solve this in Python without writing a custom class?+

Yes. Use functools.cmp_to_key to wrap a lambda comparator, or sort twice (by length, then by numeric value). The cmp_to_key approach is cleanest and directly maps to the logic.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Google.

OA at Google?
Invisible during screen share
Get it