I am trying to write a function that given a list of non negative integers, arranges them such that they form the largest possible number.
For example, given
I would love to understand from all the python experts here what is wrong with my one-liner solution. Leet code website keeps rejecting with failed tcs which works just fine on my local env.
from itertools import permutations as pm
def max_number(lst):
if all(v == 0 for v in nums):
return "0"
lst1 = [str(item) for item in lst]
return max([int(''.join(list(perm))) for perm in pm(lst, len(lst1))])