LeetCode 179. Largest Number Posted on 2021-04-13 Edited on 2024-11-24 In LeetCode 12345678const largestNumber = (nums) => { const ans = nums.map(a => a.toString()) // .sort((a, b) => (a + b) - (b + a)) // .reduce((prev, curr) => curr + prev); .sort((a, b) => (b + a) - (a + b)) .join('') return ans[0] == '0' ? '0' : ans;};