#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <queue>
#include <string>
#include <map>
#include <stack>
using namespace std;
//
// test.h
// test
//
// Created by 吴珝君 on 2018/12/31.
// Copyright © 2018年 闲着也是贤者. All rights reserved.
//
/************************************************************************/
/************************************************************************/
/*
并查集的实现
*/
/************************************************************************/
bool comepare(string a, string b)
{
return a + b < b + a;
}
string lowestStr(vector<string> vct)
{
//
string s ="";
sort(vct.begin(), vct.end(), comepare);
for (int i =0; i < vct.size(); i++)
{
s += vct[i];
}
return s;
}
int main()
{
vector<string> v;
v.push_back("ab");
v.push_back("bc");
v.push_back("cd");
v.push_back("de");
v.push_back("fg");
v.push_back("dc");
cout << lowestStr(v);
system("pause");
return 0;
}
算法第五节(第7部分求字符串的拼接后的最小串)
猜你喜欢
转载自blog.csdn.net/weixin_39804483/article/details/87739943
今日推荐
周排行