247. Largest Number

MediumStringString

Given a list of non-negative integers represented as strings, arrange them to form the largest possible number and return it as a string (if the result is all zeros, return "0"). Input: a JSON array of digit-strings.

Input: JSON array of digit-strings.

Output: Quoted string — the largest number.

Examples

Example 1
Input: ["10","2"]
Output: "210"
Explanation: 210 > 102.
Example 2
Input: ["3","30","34","5","9"]
Output: "9534330"
Explanation: Custom comparator ordering.
Example 3
Input: ["0","0"]
Output: "0"
Explanation: All zeros.

Constraints

Asked by

AdobeAccentureAmazonMicrosoftOracleGoogle
Solve this problem in the editor →