# 最大数

<p>给定一组非负整数 <code>nums</code>，重新排列每个数的顺序（每个数不可拆分）使之组成一个最大的整数。</p>

<p><strong>注意：</strong>输出结果可能非常大，所以你需要返回一个字符串而不是整数。</p>

<p> </p>

<p><strong>示例 1：</strong></p>

<pre>
<strong>输入<code>：</code></strong><code>nums = [10,2]</code>
<strong>输出：</strong><code>"210"</code></pre>

<p><strong>示例 2：</strong></p>

<pre>
<strong>输入<code>：</code></strong><code>nums = [3,30,34,5,9]</code>
<strong>输出：</strong><code>"9534330"</code>
</pre>

<p><strong>示例 3：</strong></p>

<pre>
<strong>输入<code>：</code></strong>nums = [1]
<strong>输出：</strong>"1"
</pre>

<p><strong>示例 4：</strong></p>

<pre>
<strong>输入<code>：</code></strong>nums = [10]
<strong>输出：</strong>"10"
</pre>

<p> </p>

<p><strong>提示：</strong></p>

<ul>
	<li><code>1 <= nums.length <= 100</code></li>
	<li><code>0 <= nums[i] <= 10<sup>9</sup></code></li>
</ul>


## template

```java
class Solution {
	public String largestNumber(int[] nums) {

		String[] str = new String[nums.length];

		for (int i = 0; i < nums.length; i++)
			str[i] = String.valueOf(nums[i]);

		Arrays.parallelSort(str);

		for (int i = 1; i < str.length; i++)
			for (int j = 0; j < i; j++) {
				if (str[i].length() > str[j].length() && str[i].substring(0, str[j].length()).equals(str[j])) {
					StringBuilder str1 = new StringBuilder();
					StringBuilder str2 = new StringBuilder();
					str1.append(str[i] + str[j]);
					str2.append(str[j] + str[i]);
					if (str2.toString().compareTo(str1.toString()) > 0) {
						String tmp = str[i];
						str[i] = str[j];
						str[j] = tmp;
					}
				}
			}
		StringBuilder ans = new StringBuilder();

		for (int i = str.length - 1; i >= 0; i--)
			ans.append(str[i]);

		return ans.charAt(0) == '0' ? "0" : ans.toString();
	}
}

```

## 答案

```java

```

## 选项

### A

```java

```

### B

```java

```

### C

```java

```