How can I manipulate an array to make the largest number?

前端 未结 16 2113
暖寄归人
暖寄归人 2021-01-30 02:47

Say you have an array of positive integers, manipulate them so that the concatenation of the integers of the resultant array is the largest number possible. Ex: {9,1,95,17,5}, r

16条回答
  •  日久生厌
    2021-01-30 03:11

    Well , for one you can try this

    • split the numbers into individual characters
    • sort them lexicographically in descending order
    • concat the list

    You got the largest number

提交回复
热议问题