Problem Statement |
|
You have some digits, and you want to use one or more of them to create the largest possible number. The number must have no extra leading zeroes, and no two adjacent digits can be the same. For example, "0121" and "2110" are not valid numbers.
You are given a int[] digits containing exactly 10 elements. The i-th element (0-based) is the number of digit i that you have. Return a String denoting the maximum valid number you can create.
|
|
Definition |
| Class: | RepresentNumber | Method: | maximumNumber | Parameters: | int[] | Returns: | String | Method signature: | String maximumNumber(int[] digits) | (be sure your method is public) |
|
|
|
|
Constraints |
- | digits will contain exactly 10 elements. |
- | Each element of digits will be between 0 and 50, inclusive. |
- | The sum of the elements of digits will be between 1 and 50, inclusive. |
|
Examples |
0) | |
| |
1) | |
| |
2) | |
| | Returns: "21202020202" | You can't use all the '2' digits. |
|
|
3) | |
| | Returns: "878754535352323212" | |
|
4) | |
| | Returns: "9897979767656545454343212121" | |
|