class Solution {
  public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     *
     * @param strs string字符串vector the strings
     * @return string字符串
     */
    string minString(vector<string>& strs) {
        // write code here
        if (strs.empty()) return "";
        sort(strs.begin(), strs.end(), [](const string & a, const string & b) {
            return a + b < b + a;   // 关键比较器
        });
        // 预估容量,减少拷贝
        int total = 0;
        for (auto& s : strs) total += s.size();
        string ans;
        ans.reserve(total);
        for (auto& s : strs) ans += s;
        return ans;
    }
};