//0046把数组排成最小的数
class Solution {
public:
//有点递归的意思,一开始考虑的是看位数来判断,但是挺复杂的,直接这样就好了
inline static bool cmp(string a, string b)
{
return a + b < b + a;
}
string printMinNumber(vector<int>& nums) {
vector<string>buff;
for (auto s:nums)
buff.push_back(to_string(s));
string ans = "";
sort(buff.begin(), buff.end(), cmp);
for (auto s:buff)
ans += s;
return ans;
}
};