import java.util.Arrays;
import java.util.stream.Collectors;
/**
* @author xienl
* @description
* @date 2022/8/4
*/
public class Solution {
public static void main(String[] args) {
Solution solution = new Solution();
String[] str = {"abc","de", "ab", "aa", "asd", "a", "b", "dfs"};
System.out.println(solution.minString(str));
}
public String minString (String[] strs) {
// write code here
return Arrays.stream(strs).sorted((a, b) -> (a + b).compareTo(b + a)).collect(Collectors.joining());
}
}
牛客网:NC85 拼接所有的字符串产生字典序最小的字符串
![](https://img-home.csdnimg.cn/images/20240711042549.png)