Total Complexity | 10 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | class LargestNumber |
||
8 | { |
||
9 | public static function largestNumber(array $nums): string |
||
26 | } |
||
27 | |||
28 | public static function largestNumber2(array $nums): string |
||
29 | { |
||
30 | if (empty($nums)) { |
||
31 | return ''; |
||
32 | } |
||
33 | usort($nums, static function ($a, $b) { |
||
34 | return -(($a.$b) <=> ($b.$a)); |
||
35 | }); |
||
36 | if ((int)$nums[0] === 0) { |
||
37 | return '0'; |
||
38 | } |
||
39 | |||
40 | return (string)implode('', $nums); |
||
41 | } |
||
42 | |||
43 | private static function compare(int $a, int $b): int |
||
46 | } |
||
47 | } |
||
48 |