207. Largest Number (Array to String Sort)

EasyStringString

Given a list of non-negative integers nums, arrange them such that they form the largest number.

Return the result as a string. Since the result may be very large, return it as a string.

Input format: numbers separated by '|'.

Input: Integers separated by '|'.

Output: A string representing the largest number formed by arranging the integers.

Examples

Example 1
Input: 10|2
Output: 210
Explanation: '210' > '102'; so [2,10] arrangement is better.
Example 2
Input: 3|30|34|5|9
Output: 9534330
Explanation: Optimal order: 9,5,34,3,30.
Example 3
Input: 0|0
Output: 0
Explanation: All zeros → '0'.

Constraints

Asked by

AdobeAccentureAmazonMicrosoftOracleGoogle
Solve this problem in the editor →