Ad
Code
Diff
  • from typing import List
    
    def greatest(lst: List[int]) -> int:
        nums=[0]*10
        for i in lst:
            nums[i]+=1
        result=0
    
        for digit, num in reversed(list(enumerate(nums))):
            print(digit, num)
            for j in range(num):
                result*=10
                result+=digit
        return result
    
    • from typing import List
    • def greatest(lst: List[int]) -> int:
    • str_lst = [str(n) for n in lst]
    • sorted_lst = sorted(str_lst, reverse=True)
    • result = int(''.join(sorted_lst))
    • nums=[0]*10
    • for i in lst:
    • nums[i]+=1
    • result=0
    • for digit, num in reversed(list(enumerate(nums))):
    • print(digit, num)
    • for j in range(num):
    • result*=10
    • result+=digit
    • return result