FastPrepBiggest Number From Gluing Numbers Together
Problems/Biggest Number From Gluing Numbers Together

Biggest Number From Gluing Numbers Together

Adobe logoAdobe● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: In a JavaScript-focused first round for a frontend role, one of the two coding questions was to arrange a list of numbers so that writing them side by side makes the biggest number. The report gives only that line.

It gives no limits, examples or output format. Here you return the result as a string, there are 1 to 100 numbers from 0 to 10^9, and an all-zero result is written as "0". The examples are our own.

The judged task matches the report at about 90%.

You are given a list of non-negative integers nums. Arrange them in any order and write them one after another, with no separators, to make one long number. Return the largest number you can make, as a string.

  • Every number is used exactly once, and its own digits stay in order.
  • The answer has no leading zeros: if the largest arrangement is all zeros, return "0".

Function

largestConcatenation(nums: int[]) → String

Examples

Example 1

nums = [8,81,89]return = "89881"

Compare pairs by gluing them both ways. 89 before 8 gives 898, which beats 889. 8 before 81 gives 881, which beats 818. So the order is 89, 8, 81, and the result is "89881".

Example 2

nums = [121,12]return = "12121"

12 then 121 gives 12121, while 121 then 12 gives 12112. The first is larger, even though 121 is the larger number.

Example 3

nums = [0,0,0]return = "0"

Gluing gives 000, which is the number 0. It is written without extra zeros, as "0".

Constraints

  • 1 <= nums.length <= 100
  • 0 <= nums[i] <= 10^9

More Adobe problems

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
All Adobe interview questionsSee Adobe hiring insights
Saved
public String largestConcatenation(int[] nums) {
    // Write your code here.
}
Checking account…