当前位置:首页 >> FunCtools.Cmp to kEy >>

FunCtools.Cmp to kEy

使用functools.cmp_to_key 即可。 附通过的代码: class Solution: # @param {integer[]} nums # @return {string} def largestNumber(self, nums): from functools import cmp_to_key key = cmp_to_key(lambda x,y: int(y+x)-int(x+y)) res = '...

cmp is called multiple times for each list element while key and reverse touch each element only once. Use functools.cmp_to_key() to convert an old-...

网站首页 | 网站地图
All rights reserved Powered by
copyright ©right 2010-2021。