class Solution {
void quickSort(vector<string>& strs, int l, int r)
{
if (l >= r) return;
int i = l, j = r;
while (i < j)
{
while(strs[j] + strs[l] >= strs[l] + strs[j] && i < j) j--;
while(strs[i] + strs[l] <= strs[l] + strs[i] && i < j ) i++;
swap(strs[i], strs[j]);
}
swap(strs[l], strs[i]);
quickSort(strs, l, i - 1);
quickSort(strs, i + 1, r);
}
public:
string minNumber(vector<int>& nums) {
vector<string> strs;
for (const auto & e : nums) {
strs.push_back(to_string(e));
}
quickSort(strs, 0, strs.size() - 1);
string res;
for(string s : strs) {
c++自定义排序_lambda表达式
最新推荐文章于 2024-04-09 12:40:58 发布