Largest Binary Number by Concatenation
Problem statement
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[]) → StringExamples
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^41 <= binaries[i].length1 <= sum of all string lengths <= 10^5- Every character is
0or1.