FastPrepLargest Binary Number by Concatenation
Problems/Largest Binary Number by Concatenation

Largest Binary Number by Concatenation

Adobe logoAdobe● MediumNEW GRADOA
QuestionFunctionExamplesConstraints

Problem statement

Source note: The source asks for the largest integer formed by concatenating binary strings and gives the pairwise concatenation comparator. To support results beyond a machine integer, this practice version returns the maximizing binary representation as a string and preserves its full length, including leading zeros. Bounds, examples and the callable interface are authored.

Given an array binaries of non-empty binary strings, reorder every string exactly once and concatenate them.

Return the lexicographically largest concatenation. Because all candidate concatenations have the same total length and contain only 0 and 1, this is also the largest binary value. Preserve every input character, including leading zeros.

Function

largestBinaryConcatenation(binaries: String[]) → String

Examples

Example 1

binaries = ["10","101","1"]return = "110110"

The order 1, 101, 10 produces 110110. For every adjacent pair, placing the first string before the second gives the larger pairwise concatenation.

Example 2

binaries = ["0","00","1"]return = "1000"

The string 1 must come first. The two zero-only strings commute, and all of their zeros are preserved, so the result is 1000.

Constraints

  • 1 <= binaries.length <= 10^4
  • 1 <= binaries[i].length
  • 1 <= sum of all string lengths <= 10^5
  • Every character is 0 or 1.

Source note: Screenshot of the public LeetCode discussion text describing the reported Adobe OA task. The practice version adds the details stated in the source note.

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
class Solution {
    public String largestBinaryConcatenation(String[] binaries) {
        // Write your solution here
    }
}
Checking account…