精简的C++写法,同学们不妨看一看
class Solution {
public:
string printMinNumber(vector<int>& nums) {
vector<string> res(nums.size());
for(int i = 0; i < nums.size(); ++i) //直接转化为string数组进行操作
res[i] = to_string(nums[i]);
sort(res.begin(), res.end(), [](string a, string b)->bool{return a + b < b + a;}); //lamda表达式
string ans;
for(auto x : res) ans += x;
return ans;
}
};