Given a list of non negative integers, arrange them such that they form the largest number.
For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.
Note: The result may be very large, so you need to return a string instead of an integer.
這道題要求,給定一個數組,將數組中的元素連接在一起,組成更大的數,求能組成的最大的數。由於組成的數可能很大,所以結果用字符串返回。
在解題的過程中,我傻缺了兩次/(ㄒoㄒ)/~~。第一次,沒正確審題,直接統計出所有數字的頻率,然後由大到小拼接,沒注意到一個數是不可以拆分的!第二次,不說了,說多了都是淚,直接上圖,銘記自己的蠢…
vc+jrDm089PaM6OsxMfDtDm+zdOmuMPU2jM0x7DD5qGjytfPyM7S1rG9072ryv3Xqru7zqrX1rf7tK6jrMi7uvPKudPDc3RyY21wxdC2z8G9uPbX1rf7tK61xLTz0KHAtL72tqjLrcewy62686OsuvPAtLeiz9ayu7bUo6zS8s6qscjI5zO6zTMwLKGwMzChscrHtPPT2qGwM6GxtcSjrLWrysehsDMwM6GxscihsDMzMKGx0KGho8v50tS688C0vs3Su9axz93U2rbg1tbH6b/2tcTM1sLb1tChoyA8YnI+CtfuuvO7u8HLuPbLvMK3o6zWsb3Tsci9z8G9uPbK/bK7zazX6brPtcS089Cho6yxyMjnsci9zzO6zTM0tcTPyLrzzrvWw6Osv8nS1NaxvdOxyL3PMzM0us0zNDO1xLTz0KGho8i7uvPTw9XiuPa3vbeottTV+7j2yv3X6b340NDFxdDyo6zX7rrzsNHFxbrD0PK1xMr9xrS909Ta0rvG8L7Nv8nS1MHLoaMgPGJyPgrPwsPmzPnJz7T6wuujujwvcD4KCgoKPHByZSBjbGFzcz0="brush:java;">class Solution {
public:
string largestNumber(vector