题解 | 拼接所有的字符串产生字典序最小的字符串

拼接所有的字符串产生字典序最小的字符串

https://www.nowcoder.com/practice/f1f6a1a1b6f6409b944f869dc8fd3381

#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param strs string字符串一维数组 the strings
# @return string字符串
#
from functools import cmp_to_key


class Solution:
    def minString(self, strs: List[str]) -> str:
        # write code here
        return "".join(sorted(strs,key=cmp_to_key(lambda x, y: 0 if x + y == y + x else 1 if x + y > y + x else -1)))

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务