你加我我加你
经典判断字符串拼接
C++ 代码
class Solution {
public:
static bool cmp(string a,string b)
{
return a+b<b+a;
}
string printMinNumber(vector<int>& nums) {
vector<string> t;
string res;
for(auto i:nums)
t.push_back(to_string (i));
sort(t.begin(),t.end(),cmp);
for(auto i:t)
res+=i;
return res;
}
};