Skip to content

Commit 8a31438

Browse files
authored
Create 179-largest-number.js
1 parent 97fb7b3 commit 8a31438

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

179-largest-number.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {string}
4+
*/
5+
const largestNumber = function(nums) {
6+
const arr = nums
7+
.map(v => v.toString())
8+
.sort((a, b) => (a + b < b + a ? 1 : -1))
9+
.join("");
10+
11+
return arr[0] === "0" ? "0" : arr;
12+
};

0 commit comments

Comments
 (0)