MEDIUMasked at 20 companies

Largest Number

A medium-tier problem at 41% community acceptance, tagged with Array, String, Greedy. Reported in interviews at Graviton and 19 others.

Founder's read

You've got an array of integers and you need to arrange them to form the largest possible number. Sounds simple until you realize that naive sorting fails immediately. Companies like Salesforce, Huawei, Accenture, and Zoho ask this regularly, and it shows up across 20 companies total. The trick isn't obvious, and if you blank on it during a live assessment, StealthCoder solves it invisibly while you're screen-sharing. With a 41% acceptance rate, this is a real blocker for candidates who haven't seen the pattern before.

Companies asking
20
Difficulty
MEDIUM
Acceptance
41%

Companies that ask "Largest Number"

If this hits your live OA

Largest 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 StealthCoder
What this means

The trap is comparing numbers as integers. Sort 9 and 80, and you'll put 80 first and get 8099. That's wrong. The actual approach is a custom comparator: for any two numbers a and b, sort them by which concatenation is larger (ab vs ba). If ab is bigger, a comes first. This is a Greedy pattern hidden inside a Sorting problem. Most candidates waste time on wrong comparisons before hitting the real solution. Array manipulation and String conversion are both required here. During a live OA, if you start down the integer-sort path and realize it's failing test cases, StealthCoder surfaces the comparator trick instantly, no proctor visibility.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Largest Number recycles across companies for a reason. It's medium-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.

Largest Number interview FAQ

Why can't I just sort the numbers in descending order?+

Because 9 and 80 would put 80 first, giving 8099. But 9 concatenated before 80 gives 9080, which is larger. Standard numeric sort fails. You need a custom comparator that compares concatenations (ab vs ba) instead of the numbers themselves.

Is this problem still asked at big companies?+

Yes. It appears across 20 companies including Salesforce, Huawei, and Accenture. The acceptance rate is 41%, meaning most candidates either don't see the pattern or implement the comparator wrong on first attempt.

What if the input is all zeros?+

The output should be '0', not '000...'. This is a common edge case. After sorting, check if the first character is '0'. If it is, return '0' immediately instead of the full concatenation.

How does the Greedy approach apply here?+

Greedy means always picking the locally best choice. At each position in the result, you want the digit or number that contributes the largest prefix. The custom comparator encodes that greedy decision by sorting based on concatenation size.

What language should I use to implement the comparator?+

Any language works, but Java, Python, and JavaScript are most common in assessments. Python's sorted() with a custom key function, Java's Arrays.sort() with a Comparator, and JavaScript's Array.sort() are all straightforward. The logic is language-agnostic.

Want the actual problem statement? View "Largest Number" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.